-
+67
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
/**
* Удаляет "плохие" символы в пути и заменяет пробелы на символ подчеркивания.
* Двойные кавычки заменяются на одинарные.
* @param path путь.
* @return путь с удаленными недопустимыми символами.
*/
public static String correctPath(String path) {
return correctPath(path);
}
Moloth,
06 Сентября 2013
-
+121
//development might be long and harassing
//we'll need some furniture to keep food and coffee
ckopo,
06 Сентября 2013
-
+142
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
private static string AddStr(string s1, string s2)
{
string result;
if (s1 == string.Empty)
{
result = s2;
}
else
{
if (s2 == string.Empty)
{
result = s1;
}
else
{
result = s1 + " " + s2;
}
}
return result;
}
Код - бессмысленный и беспощадный
leon_mz,
06 Сентября 2013
-
+14
- 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
constexpr const char str1[] = "Anna";
constexpr const char str2[] = "Denis";
constexpr const char str3[] = "Vladimir";
constexpr const char str4[] = "Alexey";
constexpr const char *arr[] = { str1, str2, str3, str4 };
#define GetMaxLenght(array) \
constexpr unsigned char str_len(const char* const str) \
{\
return *str ? (1 + str_len(str + 1)) : 0;\
}\
\
template <int index> \
struct MaxLenght\
{\
static const int prev_size = MaxLenght<index-1>::max_size;\
static const int cur_size = str_len(array[index]);\
static const int max_size = cur_size > prev_size ? cur_size : prev_size;\
};\
\
template <>\
struct MaxLenght<-1>\
{\
static const int max_size = 0;\
};\
static const int AmountStr = sizeof(array) / sizeof(array[0]);\
static const int array##_max_size = MaxLenght<AmountStr-1>::max_size;
GetMaxLenght(arr);
// в *.cpp
// static_assert((arr_max_size == 8), "Error");
http://habrahabr.ru/post/192736/
LispGovno,
06 Сентября 2013
-
+73
- 1
- 2
String format = String.format("%%0%dd", 2); // format = "%02d";
String seconds = String.format(format, milTime % 60);
nikanmf,
06 Сентября 2013
-
+2
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
double vvod (double a1, double a2, double a3) {
// a1=a a2=b a3=c
cout<<"Введите значение коэфицента a: ";
cin>>a1;
cout<<endl;
cout<<"Введите значение коэфицента b: ";
cin>>a2;
cout<<endl;
cout<<"Введите значение коэфицента c: ";
cin>>a3;
cout<<endl;
return (a1);
return (a2);
return (a3);
}
Оказывается в С++ можно возвращать 3 значения из функции
http://ideone.com/tGWRpl - полная версия.
pabloid,
05 Сентября 2013
-
−105
- 1
- 2
- 3
- 4
NSArray* arry = [NSArray arrayWithObjects:arrayWithObjects:prev, next, nil];
[arry performSelector:NSSelectorFromString(@"retain")];
//---
[actionSheet performSelector:@selector(setTag:) withObject:arry];
АРЦ нельзя кастовать указатели? Хватит это терпеть!
Psionic,
05 Сентября 2013
-
−1
- 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 <iostream>
using namespace std;
struct NG
{
template<class T>
struct get
{
typedef typename T::f type;
};
};
template <typename T, typename NameGetter>
struct has_member_impl
{
typedef char matched_return_type;
typedef long unmatched_return_type;
template <typename C>
static matched_return_type f(typename NameGetter::template get<C>*);
template <typename C>
static unmatched_return_type f(...);
public:
static const bool value = (sizeof(f<T>(0)) == sizeof(matched_return_type));
};
template <typename T, typename NameGetter>
struct has_member{
enum { value = has_member_impl<T, NameGetter>::value };
};
class T{};
int main() {
cout<<has_member<T, NG>::value;
return 0;
}
http://ideone.com/4LDGhZ
LispGovno,
04 Сентября 2013
-
+149
- 1
- 2
foreach (cms::hooks('template_output') as $hook_file)
require($hook_file);
хуки содержатся в отдельных файлах и вставляются в код напрямую.
fidelcomandante,
04 Сентября 2013
-
+154
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
/* Формируемый запрос через Ajax */
function MakeSearchQuery() {
searchQuery = "";
if (SearchDataQuery.CityFrom != "") {
searchQuery = "CityFrom=" + SearchDataQuery.CityFrom;
if (SearchDataQuery.Country != "") {
searchQuery += "&Country=" + SearchDataQuery.Country;
if (SearchDataQuery.Station != "" && SearchDataQuery.Station != "&Station=") {
searchQuery += "&Station=" + SearchDataQuery.Station;
}
if (SearchDataQuery.Date != "" && SearchDataQuery.Date != "&Date=") {
searchQuery += "&Date=" + SearchDataQuery.Date;
}
}
}
}
Формируемый Ajax запрос
sladkijBubaleh,
04 Сентября 2013