-
+7
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
#include <iostream>
#include <alloca.h>
#include <stdlib.h>
#include <new>
using namespace std;
int main(void) {
const size_t N = 5+rand()%4;
char* arr = ::new (alloca(N)) char[N]{1,2,3,4};
for(size_t i=0; i<N; ++i)
cout<<(int)arr[i]<<endl;
cout<<"ok";
return 0;
}
http://ideone.com/pax1TF
LispGovno,
18 Января 2014
-
+5
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
auto q = db.exec("select name from sqlite_master where type='table'");
QStringList tables;
while(q.next()) {
tables.append(q.value(0).toString());
}
if(tables.contains("searchIndex")) {
types.insert(name, DASH);
} else {
types.insert(name, ZDASH);
}
Табличек в sqlite скорее всего мало и код должен работать довольно шустро.
Но сам подход достоен QHP
https://github.com/jkozera/zeal/blob/master/zeal/zealdocsetsregistry.cpp#L27
roman-kashitsyn,
18 Января 2014
-
+15
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
#include <vector>
#include <iostream>
using namespace std;
// -- tools
// макет времени компиляции определяет количество элементов массива указанного в аргументе
template<class T, size_t N> char (&Size( T (&arr)[N] ) )[N];
// -- internal closed implementation --
int data1[] = {0, 1, 2};
char data2[] = {42};
const int ( &GetMechaData1() ) [ sizeof( Size(data1) ) ] { return data1; }
const char( &GetMechaData2() ) [ sizeof( Size(data2) ) ] { return data2; }
// -- API
//--- функции возвращают ссылки на массивы: например такого: const int[ sizeof( Size(data1) ]
const int ( &GetMechaData1() ) [ sizeof( Size(data1) ) ];
const char( &GetMechaData2() ) [ sizeof( Size(data2) ) ];
// client code
template<class T, size_t N> void ViewArray(const T (&arr)[N])
{
cout<<"data stored: \n";
for( auto& item: arr )
cout<< "item : "<<item<<endl;
}
int main()
{
ViewArray( GetMechaData1() );
ViewArray( GetMechaData2() );
return 0;
}
http://rextester.com/AEINWM88529
LispGovno,
18 Января 2014
-
+64
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
#include <iostream>
#include <typeinfo>
struct Test {};
int main()
{
std::cout << typeid(int).name() << ", " << typeid(Test).name() << std::endl;
}
Очередные КРЕСТОПРОБЛЕМЫ.
MSVC: int, struct Test
GCC: i, 4Test
http://ideone.com/KPsIlP
Вот что говорит стандарт:
The class type_info describes type information generated by the implementation. Objects of this class effectively store a pointer to a name for the type, and an encoded value suitable for comparing two types for equality or collating order. The names, encoding rule, and collating sequence for types are all unspecified and may differ between programs.
RTTI ещё бесполезнее, чем я думала.
someone,
18 Января 2014
-
+125
- 1
http://coliru.stacked-crooked.com/a/a5ba510a2075393f
Под другим ником опубликовал чуть раньше:
http://govnokod.ru/12937
crastinus,
18 Января 2014
-
+132
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
rc = system
(
"test "
"`ls -1 $WORKDIR/somedir/ | wc -l` = 1"
" -a "
"`ls -1 $WORKDIR/somedir/*/somefiles.* | wc -l` = 1"
);
ASSERTM( rc != -1, "check for number of <dirs>" );
ASSERTM( rc == 0, "number of <some> files is greater than 1" );
по мотивам http://govnokod.ru/14374
из теста. да, можно было на С написать. да, мне было просто лень.
Dummy00001,
17 Января 2014
-
+128
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<dict>
<key>author</key>
<string>Nobody</string>
<key>name</key>
<string>my-theme</string>
<key>settings</key>
<array>
<!-- ... -->
<dict>
<key>name</key>
<string>Attribute</string>
<key>scope</key>
<string>entity.other.attribute-name</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#006E28</string>
</dict>
</dict>
<!-- ... -->
</array>
</dict>
</plist>
XML. Такой загадочный и энтерпрайзный.
// Цветовая схема для Sublime Text (или TextMate)
Elvenfighter,
17 Января 2014
-
+154
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
$this->load->model('localisation/country');
$country_info = $this->model_localisation_country->getCountry($this->request->post['shipping_country_id']);
if ($country_info && $country_info['postcode_required'] && (utf8_strlen($this->request->post['shipping_postcode']) < 2) || (utf8_strlen($this->request->post['shipping_postcode']) > 10)) {
$json['error']['shipping']['postcode'] = $this->language->get('error_postcode');
}
if ($this->request->post['shipping_country_id'] == '') {
$json['error']['shipping']['country'] = $this->language->get('error_country');
}
if ($this->request->post['shipping_zone_id'] == '') {
$json['error']['shipping']['zone'] = $this->language->get('error_zone');
}
$this->load->model('localisation/country');
$country_info = $this->model_localisation_country->getCountry($this->request->post['shipping_country_id']);
if ($country_info && $country_info['postcode_required'] && (utf8_strlen($this->request->post['shipping_postcode']) < 2) || (utf8_strlen($this->request->post['shipping_postcode']) > 10)) {
$json['error']['shipping']['postcode'] = $this->language->get('error_postcode');
}
строки 279 - 301
файл catalog/controller/checkout/manual.php
opencart 1.5.5.1.1
Зачем два идентичных куска кода (1 - 6 и 16 - 21), в одном файле идущих друг за другом, я так и не понял.
gnom_virtuoz,
17 Января 2014
-
+80
- 1
- 2
if (!getBaseContext().getResources().getConfiguration().locale.getLanguage().equals(((ApplicationController)getApplication()).lang) )
((ApplicationController)getApplication()).setLocale(((ApplicationController)getApplication()).lang);
Ехал дроид через дроид, видит дроид дроид дроид
govnozmey,
16 Января 2014
-
+126
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
cnt_queue_files()->
Command = "ls "++code:lib_dir(messaging, priv)++" | grep -v ^l | wc -l",
case catch list_to_integer(string:strip(os:cmd(Command), right, $\n)) of
X when is_integer(X) -> X;
_ -> 0
end.
clear_queue_files()->
Command = "rm "++code:lib_dir(messaging, priv)++"/*",
os:cmd(Command).
create_empty_queue_file()->
Command = "touch "++code:lib_dir(messaging, priv)++"/~"++?COLD_HALT_EXCHANGE++".que",
os:cmd(Command).
Ну просто похапе какое-то.
kovyl2404,
16 Января 2014