-
+155
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
/**
* Checks if a setting is enabled
*
* @api public
*/
Manager.prototype.enabled = function (key) {
return !!this.settings[key];
};
/**
* Checks if a setting is disabled
*
* @api public
*/
Manager.prototype.disabled = function (key) {
return !this.settings[key];
};
https://github.com/LearnBoost/socket.io/blob/develop/lib/manager.js
makc3d,
28 Января 2013
-
+113
- 1
- 2
- 3
- 4
- 5
private int GenerateRandom(int MaxValue)
{
var mas = Guid.NewGuid().ToByteArray();
return BitConverter.ToInt32(mas, 4) % MaxValue;
}
....
roman-kashitsyn,
28 Января 2013
-
+41
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
public static function getById( $id )
{
$model = new self;
$data = $model->load();
foreach( $data AS $item ){
if( $item->id == $id ){
return $item;
}
}
return null;
}
Нашел в текущем проекте.
grdExh,
28 Января 2013
-
+142
- 1
- 2
if ($options->get('registrationSetup', 'requireDob')) {
// dob required
Без ДОБ-а не пущу.
DropWorld,
28 Января 2013
-
+22
- 1
- 2
- 3
- 4
list<int> list;
...
for(auto i=0;i<list.size();i++){
auto item = *next(list.begin(), i);
Вчера у меня появился каллега.
http://liveworkspace.org/code/1AWg24$5
Кажется я знаю, кто следующий будет сидеть на табуретке. Думаете стоит сказать ему?
LispGovno,
27 Января 2013
-
+130
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
import std.stdio;
class Parent{ }
class Another{ }
class Child: Parent
{
Another data;
alias data this;
this()
{
data = new Another;
}
}
void test(Parent t){writeln("Parent: ", t);}
void test(Another t){writeln("Another: ", t);}
void main() {
auto Me = new Child();
test(Me);
}
Интуитивного свежачка вам.
http://ideone.com/qEDzz
http://ideone.com/9mB8S
LispGovno,
27 Января 2013
-
+18
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
template <typename Derived>
class Base {
public:
void doSmth() {
// ...
static_cast<Derived*>(this)->OnParseAndHandle();
//...
}
};
class MyClass: public Base<MyClass> {
public:
void OnParseAndHandle() {
// ...
}
};
Если Вы не верите в виртуальные методы, то шаблоны Вам в помощь.
А может я идиот и чего-то не понял?
benderlog,
26 Января 2013
-
+32
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
// *.h
class MyClass {
public:
MyClass ();
~MyClass ();
// ..etc
};
// *.cpp
#include "*.h"
MyClass *mycl;
MyClass::MyClass ()
{
mycl=this; // эту строчку не удалять без нее не работает, точнее не всегда работает иногда сбоит
}
MyClass::~MyClass ()
{
}
Простите меня пожалуйста. Я уныл чуть мене чем полностью, но почему человек которые это написал хороший программист. Это писал не я. Извините пожалуйста за беспокойство :( ..
neudachnik,
25 Января 2013
-
+81
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
var
sMem: String;
.......
case Byte(sMem[len]) of
Word('k'): { Что то делаем };
Word('m'): { Что то делаем };
Word('g'): { Что то делаем };
end;
Вот такой вот гавнокод
haker,
25 Января 2013
-
+54
- 1
- 2
- 3
- 4
- 5
public function accuire($array = array()) {
return $this->acquire($array);
}
public function acquire($array = array()) {
Spell-master
jfhs,
25 Января 2013