- 1
path = Rails.env == 'development' ? '/Users/Razumovskiy/RubymineProjects/repetitor-js/' : '/var/www/apps/repetitor2-front-end/'
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−92
path = Rails.env == 'development' ? '/Users/Razumovskiy/RubymineProjects/repetitor-js/' : '/var/www/apps/repetitor2-front-end/'
+80
public class лаба22 {
int i;
лаба22(int k){
i=k;}
int [] a = new int [i];
void длина(){
System.out.println(a.length);
}
public static void main(String[] args) {
лаба22 s = new лаба22(5);
s.длина();
}
}
Студеньтики... тупоголовые как и их преподы
+133
HTTP referer (originally a misspelling of referrer) is an HTTP header field that identifies the address of the webpage
(i.e. the URI or IRI) that linked to the resource being requested.
Originally a misspelling of referrer...
+133
public string GenerateWinCode(String PrefixWinCode, String Name, String LastName, String NameCompany, bool IsCompany = false)
{
string _NormalWinCode = "";
if (!IsCompany)
_NormalWinCode = (PrefixWinCode + Name[0] + LastName[0]).ToUpper();
else
{
var i = 1;
try
{
while (String.IsNullOrWhiteSpace(NameCompany[i].ToString()))
{
i++;
}
_NormalWinCode = (PrefixWinCode + NameCompany[0] + NameCompany[i]).ToUpper();
}
catch (Exception)
{
_NormalWinCode = (PrefixWinCode + NameCompany[0] + NameCompany[0]).ToUpper();
}
}
if (PrefixWinCode == "IN")
throw new RuleException("ErrorWincode", Resources.Accounts.Account.WincodeInvalid);
try
{
using (var context = db)
{
var _WincodesSim =
(from q in context.UserPartners.Where(m => m.WinCode.ToUpper().StartsWith(_NormalWinCode))
where q.WinCode.Length > 4
select q.WinCode).ToList();
var _Sufix = _WincodesSim.Select(m => Convert.ToInt32(m.Substring(4))).Max();
return _NormalWinCode + (_Sufix + 1);
}
}
catch (InvalidOperationException)
{
return _NormalWinCode + 1;
}
}
Генерация уникальных ключей
+77
public static void main(String[] args) {
testIndiaLazy();
}
private static void testIndiaLazy() {
LazyInstantiator lazyInstantiator = new LazyInstantiator();
lazyInstantiator.getInstance();
lazyInstantiator.getInstance();
}
public static class LazyInstantiator {
private Object instance;
public Object getInstance() {
System.out.println("getInstance");
if (instance != null || create());
return instance;
}
private boolean create() {
System.out.println("create");
instance = new Object();
return true;
}
}
Out:
getInstance
create
getInstance
+137
#include <time.h>
int rrand(int start, int end)
{
int range=end-start+1;
int speed=1;
int base=0;
int rez=start;
if(range>200) speed=range/100;
while(range>=0)
{
srand(clock());
if(rand()%2) base=base+speed+1;
else base--;
rez=rez+base;
rez=(rez < start)? end-rez : rez;
rez=(rez > end)? (rez%end)+start : rez;
range=range-speed;
}
return rez;
}
случайные числа в определенном диапазоне...
+137
public bool StartListener()
{
bool flag;
try
{
flag = (this.m_Listener.BeginAccept() ? true : false);
}
catch (Exception exception)
{
CAssert.ReportAssert(exception);
flag = false;
}
return flag;
}
Из реального корпоративного проекта.
+156
if(!item.contact.middleInitial)
{
fullAddress = item.contact.firstName+' '+item.contact.lastName+' '
+item.contact.companyName+' '+item.streetLine1 +' '+item.city +', '+item.state +' '+item.postalCode;
}
else
{
fullAddress = item.contact.firstName+' '+item.contact.middleInitial+' '+item.contact.lastName+' '
+item.contact.companyName+' '+item.streetLine1 +' '+item.city +', '+item.state +' '+item.postalCode;
}
Сабж))
+136
for (j = 0; j < NUM_DMA_BUFFERS; j++)
*(int *)dev->channel[0].virtDma[j] = 0x1235+j;
ЯННП
+51
template<class T, size_t N>
constexpr size_t sa(T (&)[N])
{
return N;
};
static std::memory_order mmo[] =
{
memory_order_relaxed,
memory_order_consume,
memory_order_acquire,
memory_order_release,
memory_order_acq_rel,
memory_order_seq_cst
};
std::memory_order current_program_memory_order()
{
return mmo[rand()%sa(mmo)];
}
void current_program_memory_barier()
{
std::atomic_thread_fence(current_program_memory_order());
}