[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Best code snippets

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 7
Thread images: 1

Hello /g/, show me your best code snippets
>>
>>56216273
        public static void run()
{
int startsize = 8000;
int targetsize = 5000;
int maxiterations = 1000;

//conn = new SqlConnection(logconstr);
//conn.Open();

organisms = new ConcurrentBag<Organism>();
for (int i = 0; i < startsize; i++)
organisms.Add(new Organism(i));
int count = 0;
bool fail = false;
while (count < maxiterations)
{
ConcurrentBag<Organism> temp = new ConcurrentBag<Organism>();
Parallel.ForEach(organisms, (i) =>
{
var t = i.run();
if (t != null && t.isAlive)
temp.Add(t);
if (i.isAlive)
temp.Add(i);
});


if (temp.Count > targetsize && count > 100)
organisms = new ConcurrentBag<Organism>(temp.OrderByDescending(i => i.getHealth()).Take((int)(temp.Count * (-temp.Count / (targetsize * 10) + 0.90))).ToList());
else
organisms = temp;

//new Task(() =>
//{
// sqlInsert(temp.ToList(), count);
//}).Start();

Console.WriteLine("iteration: " + count + " total: " + temp.Count);
if (organisms.Count <= 100 || organisms.Count > 500000 || fail)
break;
count++;
}
generateAndInsertSummaryData(organisms);
}
>>
<code><script>
for (
i = 0; i < 100; i++
) {
alert('Op sucks ' + i + ' cocks'); }
</script></code>
>>
>>56216354
>Op sucks 1 cocks
>>
>>56216354
You'll need to declare i as a long to return how many cocks op actually sucks
>>
float returnOne(bool returnIt){
if(returnIt == true)
return (float)1;
else if(returnIt != true)
throw Exception();
}
>>
>>56217666
>declare as
>JS
Your OOP is showing
Thread posts: 7
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.