- 1
$d=str_replace('-', '.', date("Y-m-d"));
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+200.8
$d=str_replace('-', '.', date("Y-m-d"));
Дата через точку )))
+157.8
function dayTimestamp($t=null) {
if (!$t) $t = time();
$t = explode('-',date('Y-m-d',$t));
$t = mktime(0,0,0,$t[1],$t[2],$t[0]);
return $t;
}
−125.2
Sub Макрос2()
Dim pos0, pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8, pos9, digitPos As Integer
For Counter = 2 To 999999
digitPos = 1000
Set curCell = Worksheets("Лист1").Cells(Counter, 5)
Set primCell = Worksheets("Лист1").Cells(Counter, 6)
pos0 = InStr(1, primCell.Value, "0")
pos1 = InStr(1, primCell.Value, "1")
pos2 = InStr(1, primCell.Value, "2")
pos3 = InStr(1, primCell.Value, "3")
pos4 = InStr(1, primCell.Value, "4")
pos5 = InStr(1, primCell.Value, "5")
pos6 = InStr(1, primCell.Value, "6")
pos7 = InStr(1, primCell.Value, "7")
pos8 = InStr(1, primCell.Value, "8")
pos9 = InStr(1, primCell.Value, "9")
If pos0 > 0 And pos0 < digitPos Then
digitPos = pos0
End If
If pos1 > 0 And pos1 < digitPos Then
digitPos = pos1
End If
If pos2 > 0 And pos2 < digitPos Then
digitPos = pos2
End If
If pos3 > 0 And pos3 < digitPos Then
digitPos = pos3
End If
If pos4 > 0 And pos4 < digitPos Then
digitPos = pos4
End If
If pos5 > 0 And pos5 < digitPos Then
digitPos = pos5
End If
If pos6 > 0 And pos6 < digitPos Then
digitPos = pos6
End If
If pos7 > 0 And pos7 < digitPos Then
digitPos = pos7
End If
If pos8 > 0 And pos8 < digitPos Then
digitPos = pos8
End If
If pos9 > 0 And pos9 < digitPos Then
digitPos = pos9
End If
'MsgBox Left(primCell.Value, digitPos - 1)
curCell.Value = Trim(Left(primCell.Value, digitPos - 1))
Next Counter
End Sub
Я идиот и не умею программировать в excel!!
Мне надо было отрезать текст до первой цифры в одной ячейке и засунуть его в другую.
Наверное, надо было почитать про массивы в VB
−140.6
from random import randint
import sys
import re
def recupIP():
s = r"(%s)" % ("\.".join(['(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)']*4))
patt = re.compile(s)
fn = "ip.txt"
s = open(fn).read()
i = 0
global permulist
permulist = []
global recuplist
recuplist = []
while True:
m = patt.search(s, i)
if m:
recuplist.append(m.group(1))
i = m.end()+1
else:
break
#########convertir decimal au binaire###########
def decimalbinaire(string):
quotient=int(string)
liste=[]
global res
res=""
if quotient==0:
res="00000000"
else:
while quotient!=1:
liste=liste+[quotient%2]
quotient=quotient/2
liste=liste+[1]
while liste!=[]:
res=res+str(liste[-1])
liste=liste[:-1]
if len(res)<8:
octet=8-len(res)
res='0'*octet + res
return res
recupIP()
z = 0
binip,convert = [],[]
i=0
while i < len(recuplist):
string = str(recuplist[i])
string = string.split(".")
while z < len(string):
decimalbinaire(string[z])
binip.append(res)
z = z + 1
binip="".join(binip)
convert.append(binip)
i=i+1
Насколько я понял из условия того кто это делал - программа должна брать список IP-адресов, конвертить их в бинарный формат и затем, сохраняя формат, создавать новый список.
Реализацию я до конца понять не смог.
+110.2
function HexStrToint(S: String): Integer;
begin
if (s='$00000000') or (s='clBlack')then HexStrToint:=0
else
if s='$00010101' then HexStrToint:=1
else
if s='$00020202' then HexStrToint:=2
else
if s='$00030303' then HexStrToint:=3
else
if s='$00040404' then HexStrToint:=4
else
if s='$00050505' then HexStrToint:=5
else
if s='$00060606' then HexStrToint:=6
else
if s='$00070707' then HexStrToint:=7
else
if s='$00080808' then result:=8
else
if s='$00090909' then result:=9
else
if s='$000A0A0A' then result:=10
else
if s='$000B0B0B' then result:=11
else
if s='$000C0C0C' then result:=12
else
if s='$000D0D0D' then result:=13
else
if s='$000E0E0E' then result:=14
else
if s='$000F0F0F' then result:=15
else
if s='$00101010' then result:=16
else
if s='$00111111' then result:=17
else
if s='$00121212' then result:=18
else
if s='$00131313' then result:=19
else
if s='$00141414' then result:=20
else
if s='$00151515' then result:=21
else
if s='$00161616' then result:=22
else
if s='$00171717' then result:=23
else
if s='$00181818' then result:=24
else
if s='$00191919' then result:=25
else
if s='$001A1A1A' then result:=26
else
if s='$001B1B1B' then result:=27
else
if s='$001C1C1C' then result:=28
else
if s='$001D1D1D' then result:=29
else
if s='$001E1E1E' then result:=30
else
if s='$001F1F1F' then result:=31
else
if s='$00202020' then result:=32
else
if s='$001D1D1D' then result:=33
else
if s='$00222222' then result:=34
else
if s='$00232323' then result:=35
else
if s='$00242424' then result:=36
else
if s='$00252525' then result:=37
else
if s='$00262626' then result:=38
else
if s='$00272727' then result:=39
else
if s='$00282828' then result:=40
else
if s='$00292929' then result:=41
else
if s='$002A2A2A' then result:=42
else
if s='$002B2B2B' then result:=43
else
if s='$002C2C2C' then result:=44
else
if s='$002D2D2D' then result:=45
else
if s='$002E2E2E' then result:=46
else
if s='$002F2F2F' then result:=47
else
if s='$00303030' then result:=48
else
Наткнулся на проявление "гениальности"
// про язык, на котором написано, вообще молчу
Это перевод хексов оттенков серого в числа (там до 255 включительно, но здесь не влезает)
Код, может, и сгенерирован, но все равно это говнокод ^_^
+130.8
^.*rutor\.org\/(?:(?:torrent)|(?:download))\/(\d*)\/?.*
+115.2
class TReadWrapper<TItemType>
{
public static object item(string ItemString)
{
if (typeof(TItemType) == typeof(double))
return Convert.ToDouble(ItemString);
TDbg.Assert(false);
return null;
}
};
class TRead<TItemType>
{
public static TItemType item(StreamReader BinaryStream)
{
string ItemString = BinaryStream.ReadLine();
if (ItemString == null)
throw new Exception();
return (TItemType)TReadWrapper<TItemType>.item(ItemString);
}
};
class TFileToList<TListItem> : List<TListItem>
{
public TFileToList(string FileName)
{
if(typeof(TListItem)==typeof(char))
{
StreamReader file = new StreamReader(FileName, Encoding.Unicode);
string FileData = file.ReadToEnd();
foreach (char item in FileData)
this.Add((TListItem)(object)item);
file.Close();
return;
};
StreamReader fileSource = new StreamReader(FileName, Encoding.Unicode);
try
{
for (;;)
this.Add(TRead<TListItem>.item(fileSource));
}
catch
{
};
fileSource.Close();
}
}
class TListToFile<TListItem>
{
static public void rewrite(string NameOfDestinationFile, List<TListItem> Source)
{
if(typeof(TListItem)==typeof(char))
{
StreamWriter file = new StreamWriter(NameOfDestinationFile, false, Encoding.Unicode);
foreach (TListItem item in Source)
file.Write(item);
file.Flush();
file.Close();
return;
};
StreamWriter fileDestination = new StreamWriter(NameOfDestinationFile, false, Encoding.Unicode);
foreach (TListItem item in Source)
fileDestination.WriteLine(Convert.ToString(item));
fileDestination.Flush();
fileDestination.Close();
}
}
+144
<script type="text/javascript" src="/media/ddd20ce56acf1d9ebadd126322495087.js?files=jquery.js,jquery.scrollTo.js,govnokod.js,jshighlight/highlight.pack.js&v=3"></script>
<
+144.8
#ifndef __gen_spi_h
#define __gen_spi_h
#ifndef SPI_PORT_TYPE_OVERRIDE
#define SPI_PORT_TYPE unsigned int
#endif
#ifndef SPI_BYTE_TYPE_OVERRIDE
#define SPI_BYTE_TYPE unsigned char
#endif
// SPI SS SIGNAL --- OUT
#define DECL_SS(N, P, B) \
volatile SPI_PORT_TYPE *const _##N##_SS_POUT = &(P##OUT); \
volatile SPI_PORT_TYPE *const _##N##_SS_PDIR = &(P##DIR); \
const SPI_PORT_TYPE _##N##_SS_BIT = B
// SPI SCK SIGNAL --- OUT
#define DECL_SCK(N, P, B) \
volatile SPI_PORT_TYPE *const _##N##_SCK_POUT = &P##OUT; \
volatile SPI_PORT_TYPE *const _##N##_SCK_PDIR = &(P##DIR); \
const SPI_PORT_TYPE _##N##_SCK_BIT = B
// SPI MOSI SIGNAL --- OUT
#define DECL_MOSI(N, P, B) \
volatile SPI_PORT_TYPE *const _##N##_MOSI_POUT = &P##OUT; \
volatile SPI_PORT_TYPE *const _##N##_MOSI_PDIR = &P##DIR; \
const SPI_PORT_TYPE _##N##_MOSI_BIT = B
// SPI MISO SIGNAL --- IN
#define DECL_MISO(N, P, B) \
volatile SPI_PORT_TYPE *const _##N##_MISO_PIN = &P##IN; \
volatile SPI_PORT_TYPE *const _##N##_MISO_PDIR = &P##DIR; \
const SPI_PORT_TYPE _##N##_MISO_BIT = B
#define SETSS(N) *(_##N##_SS_POUT) |= _##N##_SS_BIT
#define CLRSS(N) *(_##N##_SS_POUT) &= ~(_##N##_SS_BIT)
#define SETMOSI(N) *(_##N##_MOSI_POUT) |= _##N##_MOSI_BIT
#define CLRMOSI(N) *(_##N##_MOSI_POUT) &= ~(_##N##_MOSI_BIT)
#define SETCLK(N) *(_##N##_SCK_POUT) |= _##N##_SCK_BIT
#define CLRCLK(N) *(_##N##_SCK_POUT) &= ~(_##N##_SCK_BIT)
#define READMISO(N) (((*(_##N##_MISO_PIN)) & _##N##_MISO_BIT) != 0)
#define SPI_SETUP(N) \
SETSS(N); \
*(_##N##_SCK_PDIR) |= _##N##_SCK_BIT; \
*(_##N##_MOSI_PDIR) |= _##N##_MOSI_BIT; \
*(_##N##_SS_PDIR) |= _##N##_SS_BIT; \
*(_##N##_MISO_PDIR) &= ~(_##N##_MISO_BIT); \
CLRSS(N); \
SETSS(N)
#define DECL_SPI_TRANS_BYTE(N) \
SPI_BYTE_TYPE _##N##_spi_trans_byte(SPI_BYTE_TYPE val) { \
register SPI_BYTE_TYPE bitnum; \
for (bitnum = 0; bitnum < 8; bitnum++) { \
if (val & 0x80) SETMOSI(N); \
else CLRMOSI(N); \
val <<= 1; \
SETCLK(N); \
val |= READMISO(N); \
CLRCLK(N); \
} \
return val; \
} \
#define SPI_BEGIN(N) SETSS(N);CLRSS(N)
#define SPI_END(N) SETSS(N)
#define SPI_TRANS_BYTE(N, B) _##N##_spi_trans_byte((B))
#endif
−869.4
select ST1,lower(naim||' ( '||nam||' )') from ST_REAL, (select nvl(d.k_dor, g.k_admi+200) kod, decode(:lng,'uk',n_strnus/*ua_country*/,'ru',N_Strnr/*ru*_country*/) nam from (select relsa.k_admi,N_Strnr,n_strnus from d_adm@psv_nsi relsa, d_strn@psv_nsi strana/*, arm_spr.gosdor@uzc1 doroga*/ where relsa.k_strn=strana.k_strn)