Post your code and be judged

Post your code and be judged.

Attached: scrot.png (2144x1402, 437K)

Other urls found in this thread:

aws.amazon.com/blogs/aws/amazon-s3-object-expiration/
twitter.com/SFWRedditImages

cd kode

based and kodepilled

I'm working on a new averaging system as well. I'll post it when it's done

Attached: aaa.png (796x921, 36K)

The mourning dove flown the purple sunset.

Why

>line 1201

font?

absolutely haram

macshit/10

kek/10

//because fuck dlls
static void LoadLibs()
{
var a = Assembly.GetExecutingAssembly();
foreach(var r in a.GetManifestResourceNames())
{
using(var s = a.GetManifestResourceStream(r))
{
using(var br=new BinaryReader(s))
{
var bytes = new byte[(int)s.Length];
br.Read(bytes, 0, (int)s.Length);
File.WriteAllBytes(r, bytes);
}
}
}
}

Attached: Screenshot from 2019-03-11 00-03-53.png (865x540, 43K)

if not len(s):
return []

Put: wrote 100000 lines of code in two weeks on you resume. Some might find it attractive.

Nah, rather be explicit.

if len(s) < 1:
return []

There has got to be a better way of doing what you are trying to achieve.

Ok, better the the previos one - buy why better than code from OP?

Why would you cast to bool in line 71?

i don't know.

i always like to alter/improve code after i write it
one-liners are my favorite
rldecode = lambda encoded: ''.join([c*i for c,i in encoded])

btw there is s3 object expiration

aws.amazon.com/blogs/aws/amazon-s3-object-expiration/

i actually wrote that years ago when I first started
every once in awhile I look back at that whole ~2000 line file and try to not do what I did back then

Good question.

Maybe for uniformity?

In [1]: True and []
Out[1]: []

But then, I see no way this could blow up without the bool, so the pythonic thing would be without bool.

bool exposes the fact that Python allows for Boolean conversions to things that you wouldn't typically consider to be True or False

>>> bool({})
False
>>> bool({"":False})
True
>>> bool(None)
False
>>> bool("")
False
>>> bool("hello")
True
>>> bool(500)
True
>>> bool(0)
False
>>> bool(False)
False

so if you have a list, you would prefer

if bool(mylist):
print('list is not empty')

to

if mylist:
print('list is not empty')

that's very unpythonic...

Attached: 1485953033341.gif (631x339, 958K)

just leave it off, it's redundant

Attached: Screenshot 2019-03-11 at 00.23.07.png (500x504, 48K)

int main(){
char a[100], b[100] = "", *c = "A4B8E3I1O0S5";
int i = 0, f;
gets(&a);
for(; i < strlen(a); i++) {
b[i]=a[i];
for(f = 0; f < 10; f+=2) {
if(a[i] == *(c + f)) {
b[i] = *(c+(f+1));
}
}
}
printf("%s!!!!!!!!!!", b);
return 0;
}

the things you have to do to get variadic functions in rust...

Attached: SystemRunner.png (950x638, 36K)

Open your browser console, paste this in and press Enter.

a=b=!![]+![],a--,c=b+b;while(++a)e=!(a%(c+c+b)),alert(!(a%(c+b))?e?"FizzBuzz":"Fizz":e?"Buzz":a);

Really? Where is the rustmeme goin?

cool

The !![]+![] is the cherry on top.

>here's your variadic function implementation bro

Attached: 1545073782595.jpg (1656x1532, 60K)

You can do just:
if not s:
It's actually the preferred way in Python.

same thing

it does achieve the same thing, yes, but I'm just saying it's the preferred style from both official python guidelines and google python style guide

def ZipMap(**maps):
iters = {name: iter(value) for name, value in maps.items()}
while True:
yield {name: next(iter) for name, iter in iters.items()}

bedtime nite nite

Attached: temp2.png (1534x788, 68K)

imagine how much shorter that would be with sane brackets

def multiset_combinations(ms, n):
assert sum(ms.values()) >= n
def f(ms_res, curr_val, ms_rem):
nonlocal n
if sum(ms_res.values()) == n:
yield ms_res
else:
for val in set(ms_rem):
if val >= curr_val:
val_ms = Multiset((val,)) # ideally I wouldn't need to wrap a singleton multiset
yield from f(ms_res + val_ms, val, ms_rem - val_ms)
yield from f(Multiset(), sorted(ms.keys())[0], ms)

yeah. a few lines.

>python
>vim
>janitor
>meme window decorations

Attached: proxy.soy.com.jpg (400x400, 95K)

>nonlocal
the fuck

let's see yours

function combinations(l, r)
local p = {}
r = r or #l
local function f(pos, k)
pos = pos or 1
k = k or 1
if k > r then
coroutine.yield(p)
else
for i = pos, #l - r + k do
p[k] = l[i]
f(i+1, k+1)
end
end
end
return coroutine.wrap(f)
end

for v in combinations({1, 2, 3, 4}, 2) do
print("{"..table.concat(v, ", ").."}")
end


Yeah, totally unnecessary.

o god wat
class Week
attr_reader :v,:w,:o,:n
def initialize(v,w,o,n)
@v = v
@w = w
@o = o
@n = n
end

def to_a
# calculated the night differential to be 1.16
return [v,w,o,n].zip([32.12,16.06,24.09,1.16])
end

def on_screen(wn, o=$stdout)
# format the record for display
%w(V W O N).zip(to_a).select { |c,(h,r)| h > 0 }.each do |code,(hours,rate)|
o.puts "#{wn}\t#{code}\t#{sprintf("%5.2f",hours)}\t#{sprintf("%6.2f",hours*rate)}"
end
end
end

res = db.exec(R"cowtits(
create table if not exists images(
id integer primary key not null,
md5_id integer not null,
sha256_id integer not null,
mime text not null,
size bigint not null,
filename text not null,
foreign key(md5_id) references hashes(id),
foreign key(sha256_id) references hashes(id)
);
)cowtits");

if (!res) {
panic(res.error());
}

res = db.exec(R"lactation(
create table if not exists hashes(
id integer primary key not null,
hash text unique not null,
type smallint not null
);
)lactation");

if (!res) {
panic(res.error());
}

res = db.exec(R"pettanko(
create table if not exists tags(
id integer primary key not null,
name text unique not null,
type smallint not null
);
)pettanko");

if (!res) {
panic(res.error());
}

res = db.exec(R"nopan(
create table if not exists tag_mappings(
hash_id integer not null,
tag_id integer not null,
foreign key(hash_id) references hashes(id),
foreign key(tag_id) references tags(id),
unique(hash_id, tag_id)
);
)nopan");

if (!res) {
panic(res.error());
}

Do you think my employer would mind my raw string literals if I ever showed this project to him?

local NUM_MAX = 2^53
--[[
--
-- The Croft Spiral Sieve
--
-- Essentially a 2, 3, 5 wheel-factored Sieve of Eratosthenes in generator form.
-- The generator works by not keeping the entire sieve in memory, but only the next
-- multiple of each prime the generator will come across. For example:
-- 7 is prime
-- 49 => 7 is added to the roots table and 7 is yielded
-- generator spins until the current n is 49
-- 49 is in the roots table so 49 is not prime
-- generate the next multiple of 7 that the generator will check (77) and add
-- that, mapped to its prime root (7), to the roots table
-- do this for all primes discovered so far
--
-- Doing so keep the memory usage low, as well as keeps the generator from artificial
-- bounds like a traditional sieve.
--
--]]
local function primes()
return coroutine.wrap(function()
coroutine.yield(2)
coroutine.yield(3)
coroutine.yield(5)
local wheel = {1, 7, 11, 13, 17, 19, 23, 29}
local wheelcheck = {[1] = true, [7] = true, [11] = true, [13] = true,
[17] = true, [19] = true, [23] = true, [29] = true}
local roots = {}
-- yield the primes under 30
for i = 2, #wheel do
local p = wheel[i]
coroutine.yield(p)
roots[p*p] = p
end
-- yield the rest of the primes using croft spiral sieve
for i = 30, NUM_MAX, 30 do
for _, offset in ipairs(wheel) do
local q = i+offset
if roots[q] then -- q not prime
p = roots[q]
roots[q] = nil
local x = q + 2*p
while roots[x] or not wheelcheck[x%30] do -- compute next multiple of root to be queried and add to roots dict
x = x + 2*p
end
roots[x] = p
else --q is prime
roots[q*q] = q -- add next multiple of prime to be queried to roots dict
coroutine.yield(q)
end
end
end
error("Cannot get larger primes") -- might re-implement with an mp int lib
end)
end

if you want some inline timestamp, I can do that too.
I know that identation is fucked up.

Attached: challenge_accepted.png (678x644, 80K)

And an addendum

local function decompose(n)
return coroutine.wrap(function()
for prime in Primes() do
if prime * prime > n then break end
while n % prime == 0 do
coroutine.yield(prime)
n = n / prime
end
end
if n > 1 then
coroutine.yield(n)
end
end)
end

local function cartesian_product(l)
local p = {}
local function f(d)
if d > #l then
coroutine.yield(p)
else
for i = 1, #l[d] do
p[d] = l[d][i]
f(d+1)
end
end
end
return coroutine.wrap(f, 1)
end

local function factors(n)
local decomp = Multiset(coroutinex.collect(decompose(n))
local prime, n_factors = tablex.elements(decomp)
n_factors = map(function(i) return coroutinex.collect(range(0,i-1)) end, n_factors)
return coroutine.wrap(function()
for sel in cartesian_product(n_factors) do
local factor = foldl(mul, map(function(t) return t[1]*t[2] end, zip(prime, sel))
coroutine.yield(factor)
end
end)
end
Yes, that last function has a lot of non-standard shit in it.

what's all this for? doesn't Lua have already libraries that implement that

Verilog? do you work as a embedded programmer?

Yes that's verilog, it's a bch(15,7,5) error detection and correction module/circuit
I don't call myself an embedded systems' programmer, I don't consider fpgas as embedded systems, although the 2015+ socialization with junior EE graduates indicates that this is what they call it now.
I work in digital design, mainly verilog, but the last 6 months I am working on HLS.

My embedded experience comes from programming softIP CPUs like Microblaze and hardIP ARM CPUs when it comes to Zynq fpgas.
I am designing systems on PCI-e based cards + writing pcie drivers.

Project Euler mostly. No, Lua doesn't have a library like itertools, and most languages don't have utilities for dealing with prime numbers.

def Parameterize(cls, *mixins, **attributes):
mixin_prefix = ''.join((mixin.__name__ for mixin in mixins))
parameterize = (f"{k}={v}" for k,v in attributes.items())
parameter_suffix = f"({', '.join(parameterize)})"
bases = tuple((*mixins, cls))
base_types = tuple(frozenset(type(t) for t in bases))
base_typename = ''.join((t.__name__ for t in base_types))
base_type = type(base_typename, base_types, {})
return base_type(f"{mixin_prefix}{cls.__name__}{parameter_suffix}", bases, attributes)

Nice ECC module. I'll raise you a sync (and soon async) FIFO implementation.

Attached: wew.png (720x1321, 44K)

...

cheers dude

>but the last 6 months I am working on HLS.
Ewww....

I've just had to deal with some "software guys" who decided to take a stab at writing an RSA implementation for an FPGA because HLS "made it easy". Wow, what a horrible piece of shit they wrote, and trying to get the synthesizer to generate not-total-garbage for anything larger than a trivial module requires making it look like a 90's C code base (80% macros).

Attached: headspace.png (877x636, 125K)

fn find_min_padded() {
for i in (STEP..mvl + 1 + STEP).step_by(STEP) {
unsafe {
let mv = _mm_loadu_si128(merge_val.as_ptr().add(i - STEP) as *const _);
let min_idx = _mm_minpos_epu16(mv);
let res = _mm_cvtsi128_si32(min_idx);
let val = (res & 0xFFFF) as u16;
if val < m_val {
let idx = (res >> 16) as usize + i - STEP;
m_idx = idx;
m_val = val;
}
}
}

Turns out LLVM is still faster. Fuck me, right?

I can show you my code but you can't judge me for it.


you will be judging Stackoverflow.

epic

strange code . what do you work at?

I'm judging you as hard as I can.

Attached: moon.png (370x300, 10K)

;)
HLS is pretty good, IMO but there are retards out there that know nothing about circuit designing, some of them even know a bit of verilog, and end up writing a lot of shit code.
I am not exactly working on writing HLS code, I am working on a synthesizer tool right now to analyze and optimize HLS code.

>RSA implementation
wow, that reminds me of my crypto-core design days back in 2012. pretty comfy subject, full of LFSRs. I could do that everyday. Cryptography, encoding/decoding and scrambling data is GOAT in verilog, but demands some pretty good knowledge on the respective theories, plus a good understanding on some math.
>Nice ECC module. I'll raise you a sync (and soon async) FIFO implementation.
check'd.
async fifos are a pain in the ass.
Lucky me, I just grab one from the IP library :)

File manager that uses tags rather than directory trees.

harder daddy

>I am working on a synthesizer tool right now to analyze and optimize HLS code
That sounds like a pretty difficult problem. I'm guessing you're working on the ast level?

Guess nobody cares about x86 SIMD intrinsics, huh. I just want to know if this is optimal or if there's something I'm missing. The find_min_padded is just there to remind me what it was for. The code is actually cut from other piece of code that it was in.

>Guess nobody cares about x86 SIMD intrinsics
more like nobody has used them, it's rare even for real programmers let alone Jow Forums CS students

>rust
miss me with that shit

Why would I bother? The compiler write better assembly than me, and the computer executes better than the compiler. It's not my place.

2x or more performance improvements for critical inner loops, that's why

Back in my forth days. i don't even know what the fuck this does

you might want to consider giving your variables better names, my dude

Attached: days.png (579x433, 28K)

based schizo poster

your memory is probably not properly aligned at all

Good point, I need to check that. I've been just Googling the intrinsics, probably should read Intel manual instead. There might be some initialization and finalization voodoo that make the magic sauce work.

The code works fine, it's just a sidegrade compared to the non-SIMD code the compiler writes.

Are you sure that's possible? How is what's generated deficient. If you know how it's deficient, you should know how to resolve it. Do you know how and your implementtaion of that fix is slower? Is it slower because of an assumption your code or the other code makes that it leverages?

Okay, wow... Are you sure SIMD is even a good fit for the problem? There is probably a very good reason your compiler didn't generate it (assuming you have the proper flags on).

compilers don't neccessarily generate good SIMD code, or any SIMD code

Well, the problem is sorting a partially sorted array of integers. Instead of doing full sort I can do just the merge as I already know all the locations of the concatenated sorted arrays.

Rust unstable_sort is really fast on integers, but it's also 20% of the program execution time and I've already achieved parity with SIMD, so I'd rather keep going and see how far I can push it.

Ast doesn't ring a bell,
I know what sta means though(static timing analysis)
The hardest part is to obtain behavioural verilog from the IR representation of the tool. Right now I am generating verilog via llvm ir code and xml files.
The next step is to use several known methods to optimize based on area, freq and/or locality of data.

ast = abstract syntax tree

Attached: 400px-Abstract_syntax_tree_for_Euclidean_algorithm.svg.png (400x451, 21K)

Attached: hello.png (441x190, 9K)

pretty sure the second one is actually true if /0 (aka 0) else false.
so it's true.

Some of you may recognize this from sentdex's ML tutorial.
I've made a few changes and implemented MPI for threading.

Attached: carbon.png (1770x6326, 1.22M)

>printf
bloat

Wow I posted that image awhile back lol.

The reason why I wrote it like this is because we're using a S3 compatible gateway for Ceph and AFAIK when I wrote it we didn't have that option (and we still don't I think). If we were using the real S3 though I'd probably use the object expiration like you're saying.

sf mono

Here you go you printfaggot

Attached: Screenshot_20190311-080145-picsay.jpg (1080x330, 32K)

looks like portable assembly to me

Devilish.

thats so fucking disgusting
>t.pythonfag

why do i keep getting connection error

Attached: play.sh.png (453x400, 29K)

0wn3d

Attached: meisseli.png (366x130, 4K)

kek

>light theme
Something Wrong with your eyes, user?

Attached: Screenshot 2019-03-11 at 09.32.02.png (1116x510, 110K)