- 1
CASE WHEN DAY(saledate)<10 THEN '0'+STR(DAY(saledate),1) ELSE STR(DAY(saledate),2) END + '.' + CASE WHEN MONTH(saledate)<10 THEN '0'+ STR(MONTH(saledate),1) ELSE STR(MONTH(saledate),2) END + '.'+ STR(YEAR(saledate),4) as SaleDate
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
CASE WHEN DAY(saledate)<10 THEN '0'+STR(DAY(saledate),1) ELSE STR(DAY(saledate),2) END + '.' + CASE WHEN MONTH(saledate)<10 THEN '0'+ STR(MONTH(saledate),1) ELSE STR(MONTH(saledate),2) END + '.'+ STR(YEAR(saledate),4) as SaleDate
Я у мамы программист...
convert(varchar, saledate, 104) as SaleDate
+1
Микросервисы - это хорошо или плохо?
+2
private static final String CITY_PREFIX = "г.";
private static final Map<String, String> CITIES = new HashMap<>() {
{
put("В.Новгород", "Великий Новгород");
put("Н.Новгород", "Нижний Новгород");
put("В. Новгород", "Великий Новгород");
put("Н. Новгород", "Нижний Новгород");
put("Великий Новгород", "Великий Новгород");
put("Нижний Новгород", "Нижний Новгород");
put("Петербург", "Санкт-Петербург");
put("Челны", "Набережные Челны");
put("Уренгой", "Новый Уренгой");
put("ПсковS", "Псков");
}
};
private static final Map<String, String> CITIES_WITH_PREFIX = new HashMap<>() {
{
put("г.Пушкино", "Пушкино");
}
};
ну просто офигенный мапинг
0
int ACMEncoder::Encode(int framepos, void *in, int in_avail, int *in_used, void *out, int out_avail)
{
char *pin = (char *)in;
char *pout = (char *)out;
int retval = 0;
if (!m_did_header && do_header)
{
int s = 44;
s = 4 + 4 + 12 - 4;
int t;
if (m_convert_wfx.wfx.wFormatTag == WAVE_FORMAT_PCM) t = 0x10;
else t = sizeof(WAVEFORMATEX) + m_convert_wfx.wfx.cbSize;
s += 4 + t;
if (s&1) s++;
if (m_convert_wfx.wfx.wFormatTag != WAVE_FORMAT_PCM)
s += 12;
s += 8;
if (out_avail < s) return 0;
//xx bytes of randomness
m_hlen = s;
m_did_header = 1;
out_avail -= s;
pout += s;
retval = s;
}
«Winamp» спиздили.
0
Код с продакшена рабочего проекта :-D
Dim got_new_batch As Boolean = False
Dim batch_numb As Integer = 0
Dim temp_batch As Integer = 0
While got_new_batch = False
temp_batch = objRandom.Next(400000000)
If check_batch_avaliable(temp_batch) = True Then
got_new_batch = True
batch_numb = temp_batch
End If
End While
Public Function check_batch_avaliable(ByVal batch_number As Integer) As Boolean
'CWC-7/11/2016-Rewritten to avoid runtime error
Dim RC As Integer = -1
Dim DBConnection As New IfxConnection(INFXConnectionStr_RPCentral)
'Try
Dim SQL As String = ""
SQL = " select first 1 batch_numb from " + System.Configuration.ConfigurationManager.AppSettings("InformixTable") + " where batch_numb = " & batch_number
Dim DBCommand As New IfxCommand(SQL, DBConnection)
DBCommand.CommandType = CommandType.Text
DBCommand.CommandTimeout = 200
DBConnection.Open()
RC = CInt(DBCommand.ExecuteScalar())
DBConnection.Close()
' Catch ex As Exception
' Dim ErrMsg = ex.Message
' Finally
If Not DBConnection Is Nothing Then
If DBConnection.State = ConnectionState.Open Then
DBConnection.Close()
End If
DBConnection = Nothing
End If
' End Try
If RC > 0 Then
Return False
Else
Return True
End If
End Function
+2
// https://shitcode.net/557
int getChar(char charachter){
int returnValue = Z;
switch(charachter){
case 'A': returnValue = A; break;
case 'a': returnValue = A; break;
case 'B': returnValue = B; break;
case 'b': returnValue = B; break;
case 'C': returnValue = C; break;
case 'c': returnValue = C; break;
case 'D': returnValue = D; break;
case 'd': returnValue = D; break;
case 'E': returnValue = E; break;
case 'e': returnValue = E; break;
case 'F': returnValue = F; break;
case 'f': returnValue = F; break;
case 'G': returnValue = G; break;
case 'g': returnValue = G; break;
case 'H': returnValue = H; break;
case 'h': returnValue = H; break;
case 'I': returnValue = I; break;
case 'i': returnValue = I; break;
case 'J': returnValue = J; break;
case 'j': returnValue = J; break;
case 'K': returnValue = K; break;
case 'k': returnValue = K; break;
case 'L': returnValue = L; break;
case 'l': returnValue = L; break;
case 'M': returnValue = M; break;
case 'm': returnValue = M; break;
case 'N': returnValue = N; break;
case 'n': returnValue = N; break;
case 'O': returnValue = O; break;
case 'o': returnValue = O; break;
case 'P': returnValue = P; break;
case 'p': returnValue = P; break;
case 'Q': returnValue = Q; break;
case 'q': returnValue = Q; break;
case 'R': returnValue = R; break;
case 'r': returnValue = R; break;
case 'S': returnValue = S; break;
case 's': returnValue = S; break;
case 'T': returnValue = T; break;
case 't': returnValue = T; break;
case 'U': returnValue = U; break;
case 'u': returnValue = U; break;
case 'V': returnValue = V; break;
case 'v': returnValue = V; break;
case 'W': returnValue = W; break;
case 'w': returnValue = W; break;
case 'X': returnValue = X; break;
case 'x': returnValue = X; break;
case 'Y': returnValue = Y; break;
case 'y': returnValue = Y; break;
case 'Z': returnValue = Z; break;
case 'z': returnValue = Z; break;
case ' ': returnValue = _; break;
case '3': returnValue = B2; break;
case '<': returnValue = TEMP; break;
case '*': returnValue = FULL; break;
case '|': returnValue = LINE; break;
case '_': returnValue = _; break;
case ':': returnValue = COL; break;
case '-': returnValue = DASH; break;
case ')': returnValue = BRA2; break;
case '%': returnValue = SMILE; break;
case '.': returnValue = DOT; break;
case '^': returnValue = COLDOT; break;
}
return returnValue; //RETORNO DE INFORMAÇÃO
}
Тут IsBukva до getChar допромоутили
+1
Есть случаи когда нужно 2 вызывать сборку помойки...
A = {x = "this is A"}
B = {f = A}
setmetatable(B, {__gc = function (o) print(o.f.x) end})
A, B = nil
collectgarbage() -- this is A
Роберту это называет Воскресение (Воскрешение)
https://stackoverflow.com/questions/28320213/why-do-we-need-to-call-luas-collectgarbage-twice
0
GET
0
FILE_TYPES_EXTENSIONS.each do |t, e|
if e.include? extension
return t
elsif e.any? {|_e| _e.is_a? Hash}
if _t = e.reduce({}) { |m, x| m = m.merge(x) if x.is_a?(Hash); m }.find{|_t, _e| _e.include? extension}
return retrieve_parent ? t : _t.first
end
end
end
nil
только создатель поймет, насрал и пропал
0
int removing_mask (int *x , int *y, int *lng , char board[][Y],
char *content[PL] , int select, void (*write )( int x , int y ,char board[][Y],
char *content) , int search_cross_pnt(char cross_point[LN] , int *point ,char *content[PL] , int in_x , int in_y) ,
int (*chk_mask )(char board[][Y] , int mem ,int sh, int br )
){
char mask_word[LN] = {0} ;
int sm = 1;
int lvl = 0;
int shift = 0;
int brd = 0;
int mem = 0;
int stp = 0;
int mn = 0;
int bi = 0;
int rd = 0;
int gor = 0 ,vert = 0;
int pnt = 0;
int hg = 15;
int sr = 0;
int *one_value = 0 , *second_value = 0;
int ctr = 0;
if(select == 0 ){
mem = *y;
hg = *y < LN ? *y : hg ;
}
else {
mem = *x;
hg = *x < LN ? *x : hg ;
}
for( lvl = 0 ,rd = 0; lvl <= *lng - 1 ; lvl++ ,mem++ ){
for(brd = 0 ; brd <= hg ; brd++ ){
select == 0 ? ( shift = *x , one_value = &sr , second_value = &mem) : (shift = *y , one_value = &mem , second_value = &sr ) ;
if( (select == 0 && board[ shift - 1][ *second_value ] == 0 ) || (select == 1 && board[*one_value ][shift - 1 ] == 0 )){
for( pnt = 0, stp = 0; stp <= LN ;stp++ ){
if ( chk_mask ( board , mem , shift , brd ) == 1 ){
pnt = 1;
break;
}
sr = shift++ - brd ;
mask_word[stp] = board[ *one_value ][ *second_value ] ;
}
}
if(pnt == 1 ){
break;
}
sm = search_cross_pnt( mask_word ,&mn , content ,*x, *y ) ;
if( sm > bi ){
select == 0 ? ( gor = *x - brd, vert = mem) : (gor = mem ,vert = *y - brd) ;
bi = sm ;
rd = mn;
}
}
}
if( (select == 1 && isalpha(board[gor][vert - 1] ) ||
(select == 0 && isalpha(board[gor - 1 ][vert] )) ||
( gor && vert ) == 0
) ) {
ctr = 1;
}
if( ( ( content[rd] != " " ) ) &&
( board[gor ][vert ] == content[rd][0] || !isalpha (board[gor ][vert ] ) )
&& !ctr
) {
*x = gor ;
*y = vert ;
*lng = strlen(content[rd ]);
write( gor , vert , board , content[rd] );
content[rd] = " ";
return 1 ;
}
return 0;
}
полный аут кроссворду 3 ч.