- 1
- 2
- 3
- 4
- 5
- 6
class Panel
{
// ...
friend class Panel;
// ...
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+4
class Panel
{
// ...
friend class Panel;
// ...
}
Нашёл такое в хедерах VGUI1 -- игрового тулкита от Valve для Gold Source.
Объясните, умные люди, зачем?
−1
template<typename T>
T gcd(T a, T b) {
#pragma python(gcd)
while b != 0:
a, b = b, a % b
return a
}
всех с праздником, посоны
http://codeforces.com/blog/entry/44124
0
public override void OnPropertyChanged([CallerMemberName]string propertyName = null)
{
base.OnPropertyChanged(propertyName);
if (String.Equals(propertyName, "[USERANKTARIFF]", StringComparison.CurrentCultureIgnoreCase))
{
if (((bool)this["USERANKTARIFF"]) == true)
{
this["SALARYLEVEL"] = null;
}
else
{
this["RANKTARIFF"] = null;
}
}
}
Продолжение хардкора. Мы любим ебаться с обжектами и кастами!
−2
if(this.options.raining){
this.dropletsCounter+=this.options.dropletsRate*timeScale*this.areaMultiplier;
times(this.dropletsCounter,(i)=>{
this.dropletsCounter--; // зачем это тут?
this.drawDroplet(
random(this.width/this.scale),
random(this.height/this.scale),
random(...this.options.dropletsSize,(n)=>{
return n*n;
})
)
});
завис на этой строке... https://github.com/codrops/RainEffect/blob/master/src/raindrops.js
+2
public void Initiaize(long buffersCount, int bufferSize)
{
if (bufferSize > Int32.MaxValue)
{
throw new ArgumentOutOfRangeException("bufferSize", bufferSize,
"Buffers size can't be grater than Int32 max value");
}
_bufferSize = bufferSize;
}
+2
.section-cart .table .th1.th1,
.section-cart .table .th2.th1,
.section-cart .table .th3.th1,
.section-cart .table .th4.th1 {
width: 575px;
}
.section-cart .table .th1.th2,
.section-cart .table .th2.th2,
.section-cart .table .th3.th2,
.section-cart .table .th4.th2 {
width: 285px;
}
.section-cart .table .th1.th3,
.section-cart .table .th2.th3,
.section-cart .table .th3.th3,
.section-cart .table .th4.th3 {
width: 250px;
}
.section-cart .table .th1.th1,
.section-cart .table .th2.th2,
.section-cart .table .th3.th3,
.section-cart .table .th4.th4 {
width: 250px;
}
.section-cart .table .td1,
.section-cart .table .td2,
.section-cart .table .td3,
.section-cart .table .td4,
.section-cart .table .td5,
.section-cart .table .td6 {
display: inline-block;
vertical-align: middle;
height: 215px;
border-bottom: 1px solid #d1d1d1;
}
.section-cart .table .td1.td1,
.section-cart .table .td2.td1,
.section-cart .table .td3.td1,
.section-cart .table .td4.td1,
.section-cart .table .td5.td1,
.section-cart .table .td6.td1 {
width: 245px;
line-height: 215px;
text-align: center;
}
.section-cart .table .td1.td1 img,
.section-cart .table .td2.td1 img,
.section-cart .table .td3.td1 img,
.section-cart .table .td4.td1 img,
.section-cart .table .td5.td1 img, {
.section-cart .table .td5.td1 img {
display: inline-block;
vertical-align: middle;
}
.section-cart .table .td1.td2,
.section-cart .table .td2.td2,
.section-cart .table .td3.td2,
.section-cart .table .td4.td2,
.section-cart .table .td5.td2 {
padding-left: 30px;
line-height: 215px;
padding-right: 25px;
width: 355px;
}
.section-cart .table .td1.td2 > span,
.section-cart .table .td2.td2 > span,
.section-cart .table .td3.td2 > span,
.section-cart .table .td4.td2 > span,
.section-cart .table .td5.td2 > span {
line-height: normal;
display: inline-block;
vertical-align: middle;
}
.section-cart .table .td1.td2 .title,
.section-cart .table .td2.td2 .title,
.section-cart .table .td3.td2 .title,
.section-cart .table .td4.td2 .title,
.section-cart .table .td5.td2 .title {
color: #181415;
font-size: 22px;
padding-bottom: 20px;
}
.section-cart .table .td1.td2 .opts,
.section-cart .table .td2.td2 .opts,
.section-cart .table .td3.td2 .opts,
.section-cart .table .td4.td2 .opts,
.section-cart .table .td5.td2 .opts {
font-size: 16px;
color: #636363;
line-height: 24px;
}
.section-cart .table .td1.td2 .opts b,
.section-cart .table .td2.td2 .opts b,
.section-cart .table .td3.td2 .opts b,
.section-cart .table .td4.td2 .opts b,
.section-cart .table .td5.td2 .opts b {
display: inline-block;
padding-right: 10px;
color: #181415;
}
Вот так вот строим обычную табличку.
+6
#ifdef _WIN32
...
#elif defined __linux__
std::string path;
char buff[PATH_MAX];
ssize_t len = ::readlink("/proc/self/exe", buff, sizeof(buff)-1);
if (len != -1)
{
buff[len] = '\0';
path = buff;
}
else
{
return -1;
}
int pos = path.rfind("/");
if (pos == std::string::npos)
return - 1;
path = path.substr(0, pos + 1);
path += "updater";
std::string sys_path = path;
boost::replace_all(sys_path, " ", "\\ ");
std::string rm = "rm -f ";
rm += sys_path;
system(rm.c_str());
_data.save_2_file(core::tools::from_utf8(path));
std::string chmod = "chmod 755 ";
chmod += sys_path;
system(chmod.c_str());
system(sys_path.c_str());
#endif //_WIN32
Как правильно обновлять #mailru/icqdesktop на Linux, если вы понимаете о чём я.
+2
public int Add(T item)
{
var p = m_parent as DataTreeRecord;
var i = item as DataTreeRecord;
if (m_newData == null || m_newData.Length == 0) m_newData = new T[8];
if (m_newData.Length <= m_newCount) Array.Resize(ref m_newData, m_newData.Length * 2);
if (p != null && i != null)
{
i.Parent = p;
}
m_newData[m_newCount++] = item;
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, new T[1] { item }));
return this.Count - 1;
}
Мы любим ебаться с array. List? Зачем, он медленный! Мы напишем свой ORM с аррэями и PHP внутри няшного сишарпика.
Приходилось работать с этим проектом. Это просто кладезь говнокода, и это ещё не самое ужасное место.
+2
....iv>'.(isset($row['add_descr']) ? $row['add_descr']:'').'</td....
угу, в реальном сайте, который на нашей (говно)поддержке
+2
public interface ICachedObject<TCachedValue>
{
TCachedValue Value { get; set; }
}
public interface ICacheProvider<TCachedObject, TCachedValue>
where TCachedObject : ICachedObject<TCachedValue>
{
TCachedObject Get(string key);
void Set(string key, TCachedObject value);
void Remove(string key);
IEnumerable<TCachedObject> GetAll();
}
public class CachedEntityObject : ICachedObject<IEntity>
{
public EntityState State { get; set; }
public IEntity Value { get; set; }
}
public abstract class CacheProvider<TCache, TCachedObject, TCachedValue> :
ICacheProvider<TCachedObject, TCachedValue>
where TCache : IDictionary<string, TCachedObject>
where TCachedObject : ICachedObject<TCachedValue>
{
protected TCache Cache;
protected abstract void InitializationCache();
public abstract TCachedObject Get(string key);
public abstract void Set(string key, TCachedObject value);
public abstract void Remove(string key);
public abstract IEnumerable<TCachedObject> GetAll();
}
public class CacheEntity : CacheProvider<Dictionary<string, CachedEntityObject>, CachedEntityObject, IEntity>
{
public CacheEntity()
{
InitCache();
}
protected sealed override void InitCache()
{
Cache = new Dictionary<string, CachedEntityObject>();
}
public override CachedEntityObject Get(string key)
{
if (Cache[key] == null)
throw new NullReferenceException($"{nameof(key)} not found from cache list");
return Cache[key];
}
public override void Set(string key, CachedEntityObject value)
{
Remove(key);
Cache[key] = value;
}
public override void Remove(string key)
{
if (Cache.ContainsKey(key))
Cache.Remove(key);
}
public override IEnumerable<CachedEntityObject> GetAll()
{
return Cache.Values;
}
}
Кэш сущностей