[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 32
Eating ramen while coding edition

Old: >>52240500

Ja juoda ES
>>
>>52244216
First for D
>>
First for D
>>
First for D
>>
real thread here:

>>52244247
>>52244247
>>
File: 8u.jpg (50 KB, 640x360) Image search: [Google]
8u.jpg
50 KB, 640x360
What's the most efficient algorithm to get a gf?
>>
>>52244277
This thread is much older

Many minutes older, in fact
>>
>>52244277
>404
btfo
>>
>>52244287
sudo a sandwhich
>>
>>52244261
>>52244263
>>52244270
How's it feel to shill a proprietary language?
>>
File: nsa-obama.jpg (134 KB, 1768x1057) Image search: [Google]
nsa-obama.jpg
134 KB, 1768x1057
>>52244287
I'm pretty sure bubblesort isn't the right algorithm for that
>>
File: le unamused kike.png (408 KB, 800x825) Image search: [Google]
le unamused kike.png
408 KB, 800x825
malloc: *** error for object 0x7fdc4b500190: incorrect checksum for freed object - object was probably modified after being freed.

God, why? The troublesome free is the last command in the program. I've even created dummy pointers to store the starting position of the pointers I'm working on because it gave me a "pointer being freed was not allocated" error. I can't fucking understand this shit.
>>
>>52244302
Fucking good you damn communist
>>
>>52244291

Posting for visibility.

Pls help.
>>
>>52244297
Hey, seems the mods have stopped being retards
>>
>>52244302
shameful, I'm sure

>>52244216
imageboard image downloader in python
>>
>>52244333
Fuck your digits
>>
>>52244315
There's nothing wrong with proprietary software, in a free world I should be able to sell locked boxes to people willing to buy them, but you sound like a foaming at the mouth retard and you're not helping your argument, anon.
>>
>>52244302
Breddy gud
>>
File: 1450986634415.jpg (52 KB, 507x564) Image search: [Google]
1450986634415.jpg
52 KB, 507x564
>there are people ITT who think C is low level and ancient
>>
>>52244365
You can't reason with communists. It doesn't work.
>>
>>52244380
It is though
That doesn't make it bad
>>
Why don't we meme magic an entire new language for us NEETs? Don't underestimate the power of the thought forms created by the collective unconsciousness of a large group of people.
>>
>>52244327
that was me
historically, late threads never take off, even if the first thread was something people hate, like another trap thread
>>
>>52244380
>there are people ITT who think
Good one, anon.
>>
>>52244387
explain why C is low level without using the portable assembler meme
>>
>>52244261
>>52244263
>>52244270

3DPD
>>
>>52244388
I'd rather just write everything in standards compliant C89 desu
>>
>>52244401
Because it's about as close as you'll get to the hardware without going into assembly
>>
>>52244406
this is what you get for learning a proprietary walled garden language
>>
>>52244414
>portable assembler meme
anything that doesn't serve as an abstraction for assembler opcodes is high level
you think your CPU gives a fuck what types are?
of course not, it just blindly slurps up whatever data you feed it
>>
>>52244216
I've been trying some Nong Shim Black recently and found it somewhat disappointing
It's not bad but tastes a bit bland compared to the regular Shin Ramyun
Not worth its price at all tbqh
>>
>>52244451
protip: all instant foods are going to be severely lacking when compared to real food
make your own broth and cook your own noodles, preferably with flavorings that didn't come from a packet
>>
>>52244384
You just sound like someone false flagging, you sound like a communist caricaturing what you think someone who is anti-communist would sound like.

It's not even an argument that needs to be had, they already lost the economic argument, everyone knows what happened to the countries that attempted communism. They either failed or implemented some half-arsed version of it with a mix of capitalism.
>>
File: shrug.jpg (81 KB, 600x857) Image search: [Google]
shrug.jpg
81 KB, 600x857
>>52244420
>>
File: COLA.gif (241 KB, 500x281) Image search: [Google]
COLA.gif
241 KB, 500x281
What kind of coffee does /g/ drink while programming?
>>
>>52244475
">lol proprietary" and other green style liberal shit is literally the path to communism
>>
what are we talking about
>>
>>52244491
Like I said, you just sound like someone false flagging.
>>
>>52244483
indica
>>
>>52244465
Nah, I'll just keep programming until I can afford a maid
Cooking just takes too much time for something that provides nothing after being digested
>>
>>52244508
And you sound like someone who thinks real communism has never been tried, or that the only problems with communism are pragmatic ones.
>>
>>52244513
Now he shows his true colours.
>>
>>52244529
... so you DO think real communism has never been tried
>>
>>52244451
Yeah, it was pretty meh, I think it also had tons of garlic (like actual slices of it) , right?
>>
>>52244510
>something that provides nothing after being digested
NUTRITION
it provides nutrition, you dumb shit

Cooking and experimenting with food should be something enjoyable for you unless you literally hate your life.
>not dressing up as a maid and cooking your own food
>>
>>52244561
cooking is effort
>>
>>52244567
breathing takes effort
>>
>>52244575
it does now you've reminded me you fuck

i bet you're one of those exclusive nose/mouth breathing plebs
>>
>>52244587
your life must be so hard :(
>>
Can anyone explain to me what normalizing a value/variable is and you would want to do it?
>>
>>52244603
you are now manually controlling your blinking
have fun
>>
>>52244513
It hasn't fully, no, because all attempts have rightly ended in failure.

The world wouldn't work without capitalism.

Go shill for communism elsewhere, no amount of false flagging will convert /dpt/ to communism.
>>
>>52244554
I'm not sure about the slices but it definitely tastes/smells very garlic-y
And I liked that part
I was just missing spices / oiliness

>>52244575
>>52244587
Your subconscious will automatically take care of breathing for you unless you explicitly do it yourself
It can't be compared to cooking
>>
>>52244615
you can't find a comfortable place to rest your tongue
also fuck you
>>
>>52244615
You are now aware of your agonizing loneliness
>>
>>52244620

No, communism has been tried a lot of times and it failed every time. Communism is not just fucking broken but it's fundamentally against any individual freedom and any liberty.

Fuck your conspiratorial bullshit too
>>
>>52244561
It doesn't provide anything long-term though
You just eat it, digest it, and it's gone
>>
>>52244636
>>52244647
that really aches
i could use an itch too
>>
>>52244677
you don't have to eat if you don't want to, anon
>>
>>52244216
>Literally shittest of shit tier brands
>And it's fucking ramen
Didn't know a person can fall this low
>>
>>52244696
it could be worse, you could be drinking store brand beer
>>
How can I make this less shit? It works but I hate it.
        bool altkeypressed;
void _listener_OnKeyPressed(object sender, KeyPressedArgs e)
{
if (e.KeyPressed == Key.LeftAlt)
{
altkeypressed = true;
Console.WriteLine("LALT PRESSED");
}
if (e.KeyPressed == Key.C && altkeypressed)
{
Console.WriteLine("C PRESSED");
CompleteTask();
altkeypressed = false;
}
}


http://pastebin.com/Xp4TmbtA - The listener.
>>
>>52244661
I shouldn't have responded to your first shitpost desu.

I need to stop doing this.
>>
>>52244728
why do you even need the alt-key bool?
if (e.KeyPressed == Key.LeftAlt && e.KeyPressed == Key.C)
...
else if (e.KeyPressed == Key.C)
...
>>
>>52244728
Rewrite it in Go
>>
>>52244767
Do you not think that I tried that? Do you think that this was the first method that I went for?

No, the listener refuses to accept keys in that way, hence why I've got it set up like this.
>>
>>52244728
Consider listening to WM_KEYUP events to track the state of all modifier keys

>>52244767
A keyboard hook on Windows only ever reports 1 key at a time
>>
>>52244794
Your listener is shit then, use a better framework or rewrite your program
>>
>>52244809
You want me to rewrite the Windows keyboard hook from scratch? Yeah I barely managed to cobble together the listener.

>>52244799
It's unlikely i'll be able to achieve that. I would've assumed there'd be a library for global key listeners that actually functioned seeing as the implementation is utter donkey shit.
>>
>>52244311
Post your code asshole.
>>
>>52244767
>
if (e.KeyPressed == Key.LeftAlt && e.KeyPressed == Key.C)


Do you even know anything about programming or do you come here to shitpost?
>>
>>52244832
I figured it wouldn't work, but what do I know?
I have no clue how their e.KeyPressed listener works, and maybe structs and objects work differently in C# or whatever shit proprietary language that's supposed to be?
>>
>>52244827
You can also use something like
public static bool altIsDown   { get { return ((Control.ModifierKeys & Keys.Alt) == Keys.Alt); } }

...if you are a total noob
It requires System.Windows.Forms though
>>
>>52244847
>I have no clue how their e.KeyPressed listener works, and maybe structs and objects work differently in C# or whatever shit proprietary language that's supposed to be?

I don't know a shit about C# either but how could you possibly expect a variable to hold two different values that can both be checked for equality in such fashion? I'd understand if you tried with bit flags but your post roughly equals to:
int a = 1;
if(a == 1 && a == 2)
// snip
>>
In usermode, what is stopping me from using the int instruction to raise an interrupt that an IRQ was mapped to? that would cause the OS service a fake IRQ.
Are certain interrupts protected in user mode?
>>
>>52244728
HookCallbacks() lParam contains a pointer to a KBDLLHOOKSTRUCT which appears to have what you want:
typedef struct tagKBDLLHOOKSTRUCT {
DWORD vkCode;
DWORD scanCode;
DWORD flags;
DWORD time;
ULONG_PTR dwExtraInfo;
} KBDLLHOOKSTRUCT, *PKBDLLHOOKSTRUCT, *LPKBDLLHOOKSTRUCT;

// flags:
// bit 5 The context code. The value is 1 if the ALT key is pressed; otherwise, it is 0.


so test bit 5 of ((KBDLLHOOKSTRUCT *)lParam )->flags and pass that long to your listener.
>>
>>52244865
like I said, maybe C# does something differently and keyPressed isn't so much a variable, but a function?

either way, if windows is really that retarded, adding a AltModifier boolean is the only reasonable solution
>>
>>52244852
Does it fuck, "Control" is part of System.Windows.Controls and "ModifierKeys" doesn't exist

(Keyboard.Modifiers & (ModifierKeys.Control)) == (ModifierKeys.Control))


I think is what you mean.
>>
>>52244902
>>52244852
public static bool altIsDown { get { return ((Keyboard.Modifiers & (ModifierKeys.Alt)) == (ModifierKeys.Alt)); } }  


And yeah this is a pretty solid solution, should be able to do one for each modifier key, and then just use them however I please.

Thanks.
>>
Is variable normalization basically just doing the same arithmetic operations to it (making it approach a certain value range) over different cycles?
>>
>>52244902
"Control" is also part of System.Windows.Forms

>>52244925
Np, here's what I use for all 3
public static bool altIsDown   { get { return ((Control.ModifierKeys & Keys.Alt) == Keys.Alt); } }
public static bool ctrlIsDown { get { return ((Control.ModifierKeys & Keys.Control) == Keys.Control); } }
public static bool shiftIsDown { get { return ((Control.ModifierKeys & Keys.Shift) == Keys.Shift); } }
>>
>>52244872
In protected mode each interrupt entry has a Descriptor Privilege Level (DPL) field so when you setup your interrupt vector you can specify which should be callable from level 3 (user mode) and if they should be able to elevate to 0.
>>
>>52244970
Thanks.
>>
>>52244931
What context, what kind of value?
>>
How often do you guys who work in c++ actually have to implement any kind of lock free data structure? I've been working on concurrency and serialization and serializing threads seems simple enough if you use a mutex to ensure mutual excision.


However i'm getting lost in the minutia of fined grained locking using atomic operations.

I was wondering how useful it is in general. I got passed over in my last job interview because I couldn't answer a variant of the consumer producer problem so that's why i'm studying this.
>>
Hey guys, I'm learning C, and I'm curious, will I ever really need hex and octal knowledge? Reading through the chapters with it, I just feel like "wouldn't any sane person just use decimal?" I could probably grasp it easily if I thought it was useful, but it just seems like a convoluted way to arrive at a number I could write with less input, and make a program easier to understand...
>>
>>52245050
first graduate from fizzbuzz, then we can talk
>>
>>52245050
Both are easy to learn. Hex is a must, octal isn't really useful tbqh senpai.
>>
>>52245070
Its not like I have an issue with anything else I'm reading in the book, I just see it and even the book tells me that the compiler just converts it to whatever type the number would become, which just makes me think "aren't all I'm accomplishing basically... obscuring information from somebody who might end up looking at my code?"
>>
>>52245116
like I said, graduate from fizzbuzz first
>>
>>52245136
Oh hey, I spotted the shitposter, good job. I ask a question, and you give zero input.
>>
i know you can convert hex to decimal by doing
DF6
(13x10^2) + (15x10^1) + (6x10^0)
1456


but how do I convert decimal to hex?
>>
>>52245040
Lock-free ring buffers are pretty common, implemented a bunch for various job control and shuffling data from worker threads (audio mixer being the quintessential example).
Other than that just some ad-hoc list building where you compare exchange a pointer to store release something.
Honestly you don't need many fancy data structures in most tasks, even with 'lock-free' code having lots of threads touch the same data is still bad for perf due to cache contention alone (might not even be a big difference between lock-free and locks because of that), so you tend to avoid sharing as much as possible and try to reduce it to simple ring buffers/pipes.
>>
>>52245172
... it's 13x16^2 + 15x16^1 + 6x16^0

anyway just do it backwards
simple route: find the largest power of 16 smaller than the number, find the largest multiple of that power smaller than the number, and then subtract it (that's your first hex digit)
repeat
>>
>>52245094
Any chance you could tell me what Hex would be used for? The book just says how to convert to it, but doesn't tell me what kind of use it would have.
>>
>>52245277
DF6 vs 110111110110
>>
>>52245277
Sure.
Lets say you pack to 2 4 bit values in a 8 bit value.
To get the first value:
val & 0xF0 >> 4

To get the second value:
val & 0x0F
>>
>>52245303
don't forget
D      F     6
1101 1111 0110
>>
>>52245345
all the hex digits map 1-1 with 4 bits

who could be behind this?
>>
>>52245251
ok...
1456
// find largest power of 16 smaller than num
16^2 = 256 <=
16^3 = 4096
// find largest multiple of that power smaller than num
256 * 5 = 1280

1456
1280 -
------------
0176


?????
>>
>>52245402

Yeah. As I said before, you did it wrong. DF6 isn't actually 1456.
>>
>>52245402
Also you don't just subtract and keep the remainder fucking lol

The number you multiplied the power of 16 by is the hex digit (5)
Then you repeat for the other digits
>>
>>52245423
alright, so DF6 is really 3574

>>52245439
i feel like you're glossing over important details
could you explain it from the beginning?
pretty much every method I've found involves keeping the remainder from integer division so I found it strange that yours does no such thing
>>
>>52245454
Ok here:

-> 1456
/5/ * (16^2) = 1280 (n^2 is the digit two left of the decimal point, i.e. where hundreds /would/ be (but in base 16 it's 255s))
-> 176
/11/ * (16^1) = 176 (n^1 is the digit one left of the decimal point)
-> 0
/0/ * (16^0) = 0 (n^0 is the digit immediately left of the decimal point)
0

5 (11) 0
11 is B (0 - 9 then A - F, so A is 10, B is 11, etc)

5 B 0
>>
>>52245277
It's VERY handy for system level stuff.
Mostly, it's easier to read the data packed into say, 8-bits rather than reading 8 1's and 0's.

For example, you can store 8-bits of information in one byte, so 8 flags or whatever you want, and then you 'mask' them out to retrieve the state with a bitwise 'and' like this guy >>52245326.
>>
>>52245489
It's the same to convert into any other base numeral system (e.g. binary, octal, etc) - you just replace the 16s with whatever the base is.

Hell, you could convert decimal to decimal

-> 150
/1/ * (10^2) = 100
-> 50
/5/ * (10^1) = 50
-> 0
/0/ * (10^0) = 0

150
>>
If I've got a data object like this
    public class SettingsObject
{
// Notifications
public int NotifSeconds { get; set; }
public string NotifPosition { get; set; }
}


How do I implement "INotifyPropertyChanged"? I'm trying to bind the data to controls but I'm bad at this.
>>
Working on a small DOS clone. Currently working on the heap allocator. It works, but I feel like it's pretty dodgy compared to ones others have written hahaha.

//Allocation time! Crawl through all headers until we find a hole big enough!
//We're currently losing ~512 bytes per page [assuming we allocate a single byte]... Ouch!
void* kmalloc(size_t size)
{
header_t* node;

for(node = (header_t*)KHEAP_START; node->ptr != NULL; node = node->ptr)
{
//Uncomment to view trace of walking through the block list
//kprintf("Node already allocated! Next @ %x\n", node->ptr);
}

//This block is big enough
if(node->size >= size || node->size == 0)
{
node->size = size;
node->ptr = ((uint32_t)node + size + sizeof(header_t));

kprintf("Allocating %d byte(s) at %x\n", size, ((uint32_t)node + sizeof(header_t)));
last_alloc = ((uint32_t)node + sizeof(header_t));

return (void*)((uint32_t)node + sizeof(header_t));
}
}

//Mark a block as free.
//This also checks for adjacent blocks (to the right) that are free
void kfree(void* p)
{
header_t* node = (p - sizeof(header_t));
header_t* next = (p + node->size); //Find the next block header

//It seems that the next block is also free, so adjust node's size to be the size of both blocks
if(next->ptr == NULL && next->size > 0 && node->size < 1024)
{
kprintf("The next block is free! Resizing....\n");
node->size += next->size;
kprintf("Node is now %d bytes large!\n", node->size);
}

//TODO: See if next node is free and merge the two together.
//Maybe loop through the block chain checking for NULL pointers (0)

node->ptr = NULL;
}
>>
>>52245524
in the set you'd broadcast it changed to any listeners

dunno c#
>>
>>52244287
You need the alphagorithm
>>
bit late but happy new year hiro
>>
>>52245489
12345   16^1 = 16
16^2 = 256
16^3 = 4096

HEX 3 4096 * 3 = 12288
12345 - 12888 = 57

HEX 3 16 * 3 = 48
57 - 48 = 9
HEX 9 number is less than 16

339

and yet the correct answer is 3039
what did I do wrong?
>>
>D
>proprietary
DMD has a weird nonfree license on the backend for some reason, but GDC is free
>>
        // Notifications
private int _notifseconds;
public int NotifSeconds
{
get { return _notifseconds; }
set { _notifseconds = value; OnPropertyChanged("NotifSeconds"); }
}


I set the value to "3" but my Binding
                                <TextBox x:Name="txtNotifSec"
Text="{Binding NotifSeconds}"/>


Just sits at "0" for some reason.
>>
>>52245702
you didn't have a 0 for 256

ok here's a easier way to do it
just worry about the largest power of 16 the first time around
after that, just do every next (lower) power of 16 in order
>>
Is any reason to learn Java instead of C++? Easier to find job?
>>
Guys, I came up with an idea for a new programming language..

Basically, the whole program will be some expression in polish notation and then sub expressions are evaluated recursively, replaced with their value, and then the outer expression is evaluated.

ex.

(mul 2 
(mul 2 (mod 10 7)))


Isn't it genius?
>>
>>52245730
So I always start at the highest one possible then work my way down regardless of the result?
>>
>>52245776
(I(don't(like(it)))
>>
https://www.youtube.com/watch?v=9GJd1hLWPbM
>>
>>52245779
Yeah, that's one way to do it.
>>
>>52245776
Isn't it kind of white supremacist and west-centric?
>>
>>52245776
That's basically racket
>>
>>52245805
This is bait, right?
Tell me this is bait.
>>
Maybe 5am EST isn't the right time for a joke quite like that.
>>
>>52245814
Why aren't you using UTC+1 1/2?
>>
>>52245773
If you learn C or C++ you can basically put every C-like language on your CV and learn it later if they mention that they use it

By that I mean
C
C++
C#
Objective-C
Java
PHP

Then you add in all the edgier languages that they almost certainly don't use but they'll make you look smart
D
Rust
Vala
Go
Swift
F#

If you're familiar with C, there's not a single one of these you won't be able to learn in a day
>>
>>52245824

Because I live in EST, and we all know it's the world's greatest timezone.
>>
>>52245172
>but how do I convert decimal to hex?
printf "%x\n" 1234
>>
>>52245831
>appropriating polish notation
>refusing to use their timezones
>>
File: bait.gif (3 MB, 500x207) Image search: [Google]
bait.gif
3 MB, 500x207
>>52245539
need safety guards
>>52245813
>>
File: 1znu0k9.png (16 KB, 443x339) Image search: [Google]
1znu0k9.png
16 KB, 443x339
>>52245892

The world was better when they accidentally sank into the sea.
>>
>>52245326

So, what exactly would be the point of doing that? I'm trying to figure it out, like, I assume it would save some space? Since you're fitting two values that would be 15 or below into a single byte, rather than making two variables, with a minimum size of 1 byte, for the values, but wouldn't making the program larger to use bitwise AND, as well as shifting basically get rid of the tiny bit of saved space? Or am I looking at this wrong =|
>>
>>52245922
You mean better world sank they sea
>>
>>52245961

Yes. Something to that effect.
>>
>>52245983
This is yet another reason why reverse polish notation is better

world, they sea sank better
>>
>>52245277
Hex is a convenient way to represent binary numbers.
Pure binary tends to get tediously long (reading out 64 digits of 1's and 0's is just too impractical), and binary <-> decimal doesn't have any easy patterns or 'tricks' for converting.
One hex digit can represent 4 binary digits since 2^4 = 16, so all you have to do is memorize the bit patterns for 0-15 (i. 0-F) and you can easily concatenate them to form bigger numbers (because 16 is itself a power of two).
So a random binary string: 101110010101, just group into fours: 1011 1001 0101, recall your 0-F patterns: B 9 5 -> B95

And why do we care about binary?
Bit flags/masks, checking the sign of things, packing/unpacking ints, shuffle instructions, masked moves, etc.
>>
>>52245939
Lets say you write server software in a non ethical company like Google. The server handles 1m requests every day. For the sake of simplicity, it always responds with 2 values in the range of 0-15 without any headers.
Using 32 bit values would result in: 1e6 * (32 * 2) = 64e6 bits per day.
Using 4 bit values would result in: 1e6 * (4 * 2) = 8e6 bits per day.
Now take into account that 1 bit equals to 0.01$ because using bandwidth isn't free. Do the math yourself.
>>
File: #blacklivesmatter.jpg (208 KB, 500x430) Image search: [Google]
#blacklivesmatter.jpg
208 KB, 500x430
>>52246065
>Google
>Non Ethical

Google did nothing wrong.
>>
>>52246105
>>
>>52246065
>1 bit equals to 0.01$
It's far more cheaper than that.
>>
File: curious.webm (360 KB, 400x336) Image search: [Google]
curious.webm
360 KB, 400x336
Ask your beloved programming literate anything.
>>
>>52246137
No shit, it's just an example.
>>
>>52246144
Let opinion be taken away, and no man will think himself wronged. If no man shall think himself wronged, then is there no more any such thing as wrong.
>>
Hey GTP, how much you know about ATF laws? Say you had a touch screen that controlled a firearm. the touch screen had multiple defined points on it. Any time the screen transitions from a state of none of the points being touched, to at least one point being touched, it fires a bullet. Holding a finger down on the screen does nothing, but moving it from side to side (i.e. like turning a light switch on and off) or in circles (like in a turn crank gun) would allow for rapid fire without a rapid tapping motion.

Would this be considered a machine gun by current ATF definitions?
>>
>>52246183
(-__- '') what was your question ?
>>
>>52246195

The law states that one trigger pull = one boolit. What you're suggesting MIGHT be okay, but you'd have to run it by the ATF Firearms Technology Branch. They're the ones who do the whole go / no-go thing.
>>
>>52246216
Is it not better to use what is in thy power like a free man than to desire in a slavish and abject way what is not in thy power?
>>
>>52246195
"A machine gun is a fully automatic firearm. As defined in the NFA, it is "Any weapon which shoots, is designed to shoot, or can be readily restored to shoot, automatically more than one shot without manual reloading, by a single function of the trigger."[8] Additionally, the frame or receiver of a machine gun, and any combination of parts intended to make a machine gun is legally equivalent to a complete machine gun."

What is google?
>>
If a gun designed to kill people is an assault weapon, what is the purpose of guns that are not assault weapons?
>>
>>52246238

That definition doesn't answer his question because the ATF is retarded when it comes to the nature of 'single function of the trigger'. You can actually get trigger packs for AR-15s which shoot one round when you depress the trigger and one round when you release it (effectively giving you a two round burst), because the ATF says that's TWO actions of the trigger.
>>
>>52246264

The answer is that all guns are designed to kill, and that's why we have the 2A in the first place. Keeping guns around wouldn't be very much help if they weren't so good at killing tyrants.
>>
Based bumpfire
>>
All of you fucking C language family niggers stop using four spaces for indentation, your god damn curly braces make your code disgustingly spaced out as is.
>>
>>52246302
Sir I use tabs
>>
>>52246302
{ no

}
>>
>>52246302
8 width hard tabs for you faggot.
>>
>>52246302

"tabs or death" - Patrick Henry
>>
>>52246276
Well that fits perfectly in the definition, because I think most people would describe the depressing and releasing of the trigger as two separate actions.

Even with that nuance the definition is pretty clear.
>>
>>52246338
>I think most people would describe the depressing and releasing of the trigger as two separate actions.

Some people consider the 'function' of the trigger to be the entire travel, because you can't do one without the other. In fact, before the company that designed the 2-shot trigger packs released their trigger, the TFB was still undecided on what to do.
>>
>>52244216
ES on paras ja ohjelmointi
>>
>>52246359
Well mechanically speaking it's two very separate actions, if you know a damn thing about guns I think you'd be pretty hard pressed to accept the idea that releasing the trigger is part of the action of depressing it.
>>
Fucking curly braces man, can you tell at a glance which brace is opening and which one is closing?
}
{
}
{
}
{
}
No you fucking can not, you have to put a trailing newline between every pair to make it readable. And if you have to do that, what the fuck is the point of having the braces as visual aid? None. You're just doing the compiler's job for it at no benefit to yourself.

Fucking C, I hate curly braces so god damn much.
>>
>>52246380

Trust me, I know plenty about guns. I'm saying that the TFB was undecided on what constituted a 'function' of the trigger.

Gun laws are truly nonsensical.
>>
>>52246387
>what is a code editor
>why am i not using an ide? is it because i am a faggot?
>>
>>52246399
Yep that's why we just banned them all entirely and added a few heavily restricted exceptions.

I much prefer my odds running away from a knife than I do running from a bullet.
>>
File: 1450848951655.jpg (122 KB, 800x551) Image search: [Google]
1450848951655.jpg
122 KB, 800x551
>>52246417

That sounds pretty queer, lad. I love my guns. I would never give them up.

>I much prefer my odds running away from a knife than I do running from a bullet.

If you're within 21 feet, knife wins. That is, unless you already have your gun out.
>>
>>52244216
>pikanuudeli
top kek torilla tavataan. I need some project ideas, where's the image with challenges?
>>
>>52246437
>If you're within 21 feet, knife wins. That is, unless you already have your gun out.

What?

I'm pretty quick on my feet, I think I'd be relatively safe to run from a knife wielding chav from a metre or two away.
>>
Daily reminder that guns are for people too afraid to fight ISIS.

Facebook is never wrong.
>>
>>52246472
All they have to do is lunge.
You have to see the lunge, react to the lunge, turn your body 180 degrees and out-accelerate their lunge in that process.
If you decided to turn and run first, all of the above still applies.
>>
>>52246472
>What?

It's the 21 foot rule. Guy with a knife will already be in the process of killing guy with a gun by the time he gets his gun out.

Luckily, most people pull weapons and don't intend on using them. That makes it very easy to respond by shooting them for threatening you.

>I think I'd be relatively safe to run from a knife wielding chav from a metre or two away.

You'd already be on your way to the hospital, lad.
>>
>>52246387
>can you tell at a glance which brace is opening and which one is closing
Yes, because I'm not fucking blind
>>
>>52246491
21 foot rule, aside from being a fucking rule and not the word of god, does not apply if you're running the fuck away

if you're gonna bring named shit up to show you're so knowledgeable like some kind of autist at least do it right
>>
>>52246535
>does not apply if you're running the fuck away

So you're pre-emptively running away from people every time you get within ~6.5 meters of them? Sounds pretty queer to me, lad.

We just shoot them.

Easy peasy.
>>
File: kekcat1.gif (2 MB, 500x284) Image search: [Google]
kekcat1.gif
2 MB, 500x284
Does /dpt/ have any time management advice to share? I have a very hard time getting shit done.
>>
>21 foot rule
What if you trip the guy, and then shoot him while he's on the ground, trying to reach for the knife that just flew out of his hand?
>>
File: Interviewer.jpg (17 KB, 350x244) Image search: [Google]
Interviewer.jpg
17 KB, 350x244
>alright, for this next part, i want you to convert the hexadecimal value 404193 to decimal using any method you'd like, here's a piece of paper
wat do?
>>
>>52246578
Isn't 404193 in hex the same in dec?
>>
>>52244216
Juoko AP ES:ää ja syö ES nuudeleita ohjelmoidessaan ja runkatessaan animelle?
>>
>>52246553
21 foot rule:

if someone is charging at you with a knife, in the time an average trained person can notice and try to get their gun out, and fire 2 or 3 clean and accurate shots, they will have reached you

if you see someone pulling a knife you back the fuck up one way or another, whether you're going for a gun, running or for unarmed knife defences

best move is probably to go for your baton

>>52246577
What if you do a spinning kick and decapitate him?
>>
>>52246588
kaksoispiste ddddd.

Im busy hacking ylilauta
>>
>>52246577

And what if you were Neo and John Wayne combined? And what if candy canes shot out of your ass?

I'm just fucking with you. Good luck getting around the 21 foot rule if you don't have your gun drawn already. You MIGHT be able to swing it if you do that whole gun-on-a-rail up your sleeve thing like Taxi Driver. Then again, if you do that, you have to stand in front of the mirror for a few hours saying "You talkin' to me?"
>>
>>52246586
no, it's a base-16 number
>>
>>52246593
>if you see someone pulling a knife

That's the thing, this isn't predictable. They could be 3 feet behind you and pull the knife, and it's pretty much game over.
>>
>>52246578
B = 16
N: 4 0 4 1 9 3
X: 5-4-3-2-1-0

Σ(N_k[B^(X_k)])
k
>>
>>52246638
Yeah, then you die, what's your point?
>>
>having a function with more than 5 lines of code
You have 10 seconds to explain why you don't refactor your code
>>
>>52246670
>what's your point?

That somebody doesn't need a gun to kill you. :)

And don't lie, everybody loves guns. They're the coolest shit of all time. Anyone who claims they have no interest is a fucking liar.

God bless America.
>>
>>52246691
Because I don't write functions with more than 5 lines of code. Why, do you?
>>
>/dpt/ - getting stabbed by niggers and chavs
>>
>>52246713

Pro-tip: shoot & scoot
>>
File: python.jpg (435 KB, 2000x1334) Image search: [Google]
python.jpg
435 KB, 2000x1334
What's the worst programming language?
>>
File: RpCohdc.gif (2 MB, 250x360) Image search: [Google]
RpCohdc.gif
2 MB, 250x360
>>52246566
https://en.wikipedia.org/wiki/Pomodoro_Technique
>>
Rust memcpy:
#[no_mangle]
pub fn memcpy(dst: *mut u8, src: *const u8, count: usize) {
for i in 0..count {
let d = (dst as usize + i) as *mut u8;
let s = (src as usize + i) as *const u8;
unsafe { *d = *s; }
}
}


Generated assembly:
00000000000000a0 <memcpy>:
a0: test r8,r8
a3: je 10f <memcpy+0x6f>
a5: lea r9,[r8-0x1]
a9: xor r11d,r11d
ac: test r8b,0x3
b0: je d1 <memcpy+0x31>
b2: mov r10d,r8d
b5: and r10d,0x3
b9: xor r11d,r11d
bc: nop DWORD PTR [rax+0x0]
c0: mov al,BYTE PTR [rdx+r11*1]
c4: mov BYTE PTR [rcx+r11*1],al
c8: lea r11,[r11+0x1]
cc: cmp r10,r11
cf: jne c0 <memcpy+0x20>
d1: cmp r9,0x3
d5: jb 10f <memcpy+0x6f>
d7: nop WORD PTR [rax+rax*1+0x0]
e0: mov al,BYTE PTR [rdx+r11*1]
e4: mov BYTE PTR [rcx+r11*1],al
e8: mov al,BYTE PTR [rdx+r11*1+0x1]
ed: mov BYTE PTR [rcx+r11*1+0x1],al
f2: mov al,BYTE PTR [rdx+r11*1+0x2]
f7: mov BYTE PTR [rcx+r11*1+0x2],al
fc: mov al,BYTE PTR [rdx+r11*1+0x3]
101: mov BYTE PTR [rcx+r11*1+0x3],al
106: lea r11,[r11+0x4]
10a: cmp r8,r11
10d: jne e0 <memcpy+0x40>
10f: ret


The fuck? Why does it perform 4 1-byte copies in a row? Aside from the fact that it's supposed to copy 1 byte at a time, x86 has better instructions for copying 4 bytes at a time.
>>
>>52246731
Java. I say this after learning C#, C++, and some Python, all after Java.
>>
File: 1438277996876.jpg (22 KB, 480x360) Image search: [Google]
1438277996876.jpg
22 KB, 480x360
>>52246742
>unsafe
>>
first for Go
>>
>>52246771
>Go programs are O(-n)
>>
>>52246742
>nop
>actually performs an operation
x86 is literally shit
>>
>>52246804
>implying no-op shouldn't be an operation
>>
File: 12.png (744 KB, 1024x768) Image search: [Google]
12.png
744 KB, 1024x768
>>52244216
ebin ES :---DDDD
>>
Is there a better way to do this?
 switch (hex)
{
case 10: out[j] = 'A'; break;
case 11: out[j] = 'B'; break;
case 12: out[j] = 'C'; break;
case 13: out[j] = 'D'; break;
case 14: out[j] = 'E'; break;
case 15: out[j] = 'F'; break;
default: out[j] = hex + '0';
>>
>>52246876
(N-10) + 'A'
>>
>>52246883
THATS NOT UTF8 AWARE

BAD CODE
BAD!!!!!!!!!!!!!!!!
>>
File: HELLO DARKNESS MY OLD FRIEND.gif (1 MB, 320x180) Image search: [Google]
HELLO DARKNESS MY OLD FRIEND.gif
1 MB, 320x180
>GDC compiled a 63 byte hello world source file to a 13.0MB executable
apparently GDC likes to statically link the debug version of the standard library by default

how do I fix this?
>>
>>52246908
it is if the 'A' is qt-fate
>>
>>52246916
-nophoboslib
>>
>>52246946
>-nophoboslib
I've never used tango though
is it good? Is there solid documentation on it somewhere?
>>
>>52244287
Berlekamp–Massey algorithm
>>
>>52246804
tons of real assembly languages have nop
>>
>>52246883
lel nope, don't do this.
>>
What's a good practical book on modern algorithms?
I don't give a flying fuck about the theory behind an algorithm and how to prove it, I only want to know how it works and how to implement it and some benchmarks.

There are some books like that that I already have, but they only contain ancient algorithms from the 80s, no new stuff.

Any suggestions?
>>
>>52246961
i don't know anything about tango either. if you need a standard library though, maybe you can dynamically link phobos?
http://prowiki.org/wiki4d/wiki.cgi?D__Tutorial/CompilingLinkingD#Linkingmanually

or maybe this thread might have some ideas:
http://forum.dlang.org/thread/[email protected]
>>
>Nudler met cuckingsmak
>>
>>52246992
literally nothing wrong with this
>>
>>52246994
Why would you want to learn how to implement an algorithm without knowing how it works?

How would you even decide that you're doing it right?
>>
>>52246994
>ancient algorithms

Quicksort was invented in 1959. Never forget that.
>>
>>52246566
Think of all the shit that cats brain had to process to make those set of movements, Amazing when you think about it.

> Eat
> Huh, intuition is making me feel weird, scan surroundings
> Fuck
> Don't like that, check exit path
> Jump, Wallbounce

All in a second.
>>
>>52247003
Knowing how an algorithm works is different from knowing the mathematical theory behind it or being able to prove it.
>>
>>52247013
All the good algorithms (sqrt, primes, sine/cosine) were invented over a thousand years ago
>>
>>52244401
>implying you are doing anything of worth if you think that way
It's true that /g/ likes to use C for everything, even things it's overkill.
It's very low language, very close to hardware. That's why it's used in programming uControllers.
Why don't you just use VHDL if you want to meme?
>>
>>52247024

That's true. People are pretty fucking clever.
>>
>>52247022
no
no it isn't
>>
>>52247024
Sleep sort

>inb4 """good"""
>>
>>52247034
Sorting by weight is the same principle as sleep sort
>>
>>52247031
Shut the fuck up dude, all you need is something that you can plug into a program and tweak it for your specific use case.

Similarly how you don't need to read the library source code to use the API.

Next you'll tell me everyone should write their own game engine.
>>
>>52246994
>Ancient algorithms from the 80s
We are still using algorithms invented during the times of Ancient Greece. Good algorithms don't just magically become obsolete.
>>
>>52247045
"Sorting by weight" is a nondescriptive sorting algorithm.
You could have said "sorting in ascending order" and it would have meant exactly the same thing.

Sleepsort() is more obvious in that everyone who knows what sleep() does, knows that the algorithm is based on threading.
>>
>>52246995
Well the first link is DMD on windows
The second link is just a few options that achieve like a ~20% reduction in executable size

by running strip on the output I can get it down to 1.8MB but that's still clearly not an acceptable size for hello world

I'll keep looking, maybe ask on the forums
>>
>>52246700
Holy shit, that's cool.

I bet it jams and fucks up constantly though.
>>
>>52247075

It was very likely a one-off, and rarely if ever used.

We may never know how useful it really was.
>>
>>52247062
Sure, but there might be more recent implementations that work better for specific use cases that weren't around fifty years ago.
>>
>>52246908
>Implying A-F is not the same in ASCII and UTF-8
>>
>>52247050
Holy shit why the salt?
Knowing how an algorithm works is the same as knowing how it works "mathematically"
What you apparently meant is that you don't need to know how it works to use it because you can just copy pseudocode
>>
>>52247082
Of course. My point was that dismissing algorithms simply because they might be "ancient" is retarded.
>>
>>52246691
I've got functions that are literally 100+ lines.

How do I get the drive to actually take the time and refactor?
>>
>>52247062
I think he might be referring to the tendency of algorithms 'from the 80s' to be implemented, or even only implementable, in a way that's e.g. way heavier (relatively) on memory read/write as opposed to CPU than would be considered appropriate on modern systems given how much hardware profiles have changed since then

It's an extremely rare problem to have with algorithms but I suppose it's possible
>>
File: nigger.webm (973 KB, 1226x1000) Image search: [Google]
nigger.webm
973 KB, 1226x1000
>>52247081
got a present for you senpai
>>
>>52247106

Well now.. that's a bit of a throwback.
>>
>>52247106
pls post code
>>
>>52247104
"If it is not right, do not do it" - marcus aurelius
>>
>>52247094
I should have used "obsolete" instead of "ancient", but the point stands.

I don't give a shit how insertion sort works because I'm never going to use it.
>>
>>52246387
This right here is exactly why opening braces should NEVER be on a new line.
>>
>>52247113
it's not clean though
>>
>>52246387
function {
switch {
...
}
if {
...
} else {
...
}
}

So confusing!
>>
>>52247128
I disagree.

Allman style is best style.
>>
>>52246387
>>52247128
what are indentations
>>
>>52247148
awwww famalam :(. Is it completely unreadable?

If not, paste-bin it, you are anonymous, no judgement from here.
>>
File: squirtle eating a pear.jpg (24 KB, 484x365) Image search: [Google]
squirtle eating a pear.jpg
24 KB, 484x365
>LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../:/lib/:/usr/lib/
>>
>>52247168
I will vocally judge him on his shit code
>>
>>52247163
If you're already relying solely on indentations for code readability, why not do away with curly braces? :^)
>>
god damn WinAPI is so fucking ugly I can't believe this platform is still around
>>
I overengineered my number base converter, is it even possible to have a number system larger than base36?
>>
>>52247179
Because scope being specified strictly should be the domain of the programmer and not the compiler :^)
Thread replies: 255
Thread images: 32

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.