[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: 36
File: Compiler.jpg (193 KB, 797x506) Image search: [Google]
Compiler.jpg
193 KB, 797x506
Interviews edition

Old: >>55449980
>>
>>55459573
Does std::next wrap around if it hits the end of something?
>>
File: himegoto considered harmful.png (1 MB, 1000x1400) Image search: [Google]
himegoto considered harmful.png
1 MB, 1000x1400
Too early edition
>>
>>55459573
TOO EARLY
>>
>>55459598
Nope.
>>
File: boogeyman.jpg (83 KB, 1920x1080) Image search: [Google]
boogeyman.jpg
83 KB, 1920x1080
UH OH, /G/!

You've been visited by the BAD CODE BOOGEYMAN! You will leave this thread unharmed only if you post something you coded recently and the boogeyman sees there's no bad code in it!

C'mon, you guys don't have anything to fear, right?
>>
>>55459573

Continued adventurers of the chip8 emulator.. Looking at Vulkano as a potential for graphics https://github.com/tomaka/vulkano

True story this has taken so long because I only work on it for about 15 - 30 minutes a day..
>>
>>55459652
main = print "God bless you immunity cat"
>>
>>55459652
Sorry bro, immunity cat is protecting me
>>
>>55459652
Am I safe?
int x = 0;
>>
>>55459641
there's no need to be rude
>>
>>55459652
nice try but immunity cat is ALWAYS with me.
>>
>>55459702
But I wasn't trying to be rude. :(
>>
>>55459652
std::copy(std::begin(uartData), std::end(uartData), std::back_inserter(resultData))
>>
>>55459652

Immunity cat guards the dpt..
>>
>>55459652
mov ax, 1
>>
File: output.png (232 KB, 960x540) Image search: [Google]
output.png
232 KB, 960x540
>>55459652
3D rendering computed fractals
>>
>>55459715
std::copy(
std::begin(uartData),
std::end(uartData),
std::back_inserter(resultData)
)
>>
>>55459766

Only use powers / multiples / divisors of 12 when you're generating the fractals. It'll provide interesting results.
>>
File: 1464184024022.jpg (44 KB, 640x640) Image search: [Google]
1464184024022.jpg
44 KB, 640x640
>tfw all the videos in my BGM playlist were flagged by Youtube
>no more rare pc-98 tracks to program to
>>
>>55459814
The real project generates a random function from a
list of functions and generates the images. The 3D part is a thing I was working on to export the data to OBJ.
>>
>>55459715
>>55459798

{
using namespace std;
copy(begin(uartData), end(uartData), back_inserter(resultData));
};
>>
In C, how do I make scanf accept n number of inputs?

For example, if I wanted it to accept 5 integers, I would simply write

scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);

The idea is, for an array of size n, I should be able to make scanf accept n numbers of input, all to be deposited into the array.
>>
>>55459903
int arr[5];

for (int i = 0; i < 5; ++i)
scanf("%d", &arr[i]);
>>
>>55459652
Is this good or bad code, mr. boogeyman?

#define/**/install/**/0[x]=045;p(j);p(k);for(;;){++l;m++;++q;r++;
#define gentoo if((l-44)>>6){p(l);p(l);break;}}m|=3;q^=27;p(m); \
r+=6;t>>=2;t+=7;p(t);p(q);p(m);p(r);p(l) ;p(s); t++;p(t) ;p(10);}
#define/**/i/**/int/*/a/ /b/ /c/ /d/ /e/ /f/ /g/ /gif/ /h/ /hr/*/
#define/**/c/* */char/*/k/ /m/ /o/ /p/ /r/ /s/ /t/ /u/ /v/ /vg/*/
#define/**/Anonymous/**/1[x] b-1;i Thu b;j+=4;k++;i a=// /vr/ /w/
#define/* */b/* */=0144/* /wg/ /i/ /ic/ /r9k/ /s4s/ /cm/ /hm/ */
c x[2];i j b,No b,k b,l b,m b,q b,r b,s b,t b;main(){ //lgbt/ /y/
#define p(o) printf(x, o) //3/ /aco/ /adv/ /an/ /asp/ /biz/ /cgl/


Anonymous 07/07/16*(Thu)*11;25;11*No*55458155;

install gentoo
>>
I'm pre-ordering a binary tree in java and returning the String result of the pre-order. My methods are traversing the tree properly but it is deleting my string, so that the end result when printed out is only the root node in my tree.
public String preOrder() {
String answer = "";
return preOrderHelper(root, answer);

}

private String preOrderHelper(Node root, String answer){
if(root == null){
return answer;
}
answer = answer + root.key + " ";
preOrderHelper(root.left, answer);
preOrderHelper(root.right, answer);
return answer;
}
>>
>>55459962
what the fug
>>
>>55459943
Okay I think I worded my question wrongly..

Basically, I have a pointer to an array passed to a function. The size of the array is not fixed. I have to write a scanf that accepts input based on the size of that array, and write those inputs to the array itself.

Your solution would work if the array size is fixed, but unfortunately my case isn't.
>>
>>55459693
Indescriptive name. What the hell does x mean? It's not even something standard, like i or j in loops, or n as size of something, or T in generics/templates, or e in range-based for loops, et cetera et cetera.
>>
>>55459962
Don't compile that, it releases mustard gas!
>>
>>55460088
>there are no possible situations where x can be a reasonable variable name
>>
>>55460080
Oh, then just use malloc, and realloc to get as much memory as you need for the input.
>>
>>55460080
use an struct that has a pointer to the array and the size of the array.
>>
>>55460017
This will work:
answer = preOrderHelper(root.left, answer);
answer = preOrderHelper(root.right, answer);

Since you seem to want to do things to a traversed tree, why not write one function to turn your tree into a pre-order list and another function to turn a list into a string?
private List<Node> preOrder(Node root) { ... } 
private String toString(List<Node>) { ... }

toString(preOrder(root));
>>
>>55460153
>>55460173

Do I have to use those right now? Because the point is, I'm currently following this course, and it hasn't touched on malloc or struct right now.
>>
>>55459652
static PyObject* decode(PyObject* self, PyObject* args)
{
Py_buffer buffer;
PyObject* retval;
char* decoded;
char ch;
size_t i = 0, j = 0;

if (!PyArg_ParseTuple(args, "y*", &buffer)) return NULL;
if ((decoded = (char*) PyMem_Malloc(buffer.len)) == NULL) return PyErr_NoMemory();

for (i = 0, ch = ((char*)buffer.buf)[i]; i < buffer.len; ch = ((char*)buffer.buf)[++i])
{
if (0x0A == ch || 0x0D == ch) continue;

if (0x3D == ch)
ch = ((char*)buffer.buf)[++i] - 106;
else
ch -= 42;

decoded[j++] = ch;
}

retval = PyBytes_FromStringAndSize(decoded, j);
PyMem_Free(decoded);
return retval;
}


Boogeyman is going to fuck my shit up
>>
>>55460194
You can't unspecify the size of the array in its declaration if it has zero elements, and then pass it to a function. How does the code look like?
>>
>>55460194
So you're problem is you have an array and dont know the size? That should be easy to figure out.
>>
>>55460194
you should have told us that you are a noob. just use a fixed length array, keep track of the number of inputs in a variable and do something like >>55459943
>>
should I study pre calculus/calculus in order to be a good programmer? I am learning via sicp now, but I have some free time as well, so maybe it will be helpful to start learning precalculus right now?
>>
>>55460307
What's 'pre-calculus'?
>>
This is a python script to remove any leading non-alphabetical characters in a directory.

I don't know why it would be of use to anyone but me but here you go:


import os


stop = False


def isalpha(x):

"""Returns true if character passed in is alphabetical"""


if x in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ":

return True

else:

return False


for filename in os.listdir("."):

num = -1

for c in filename:

if stop:

stop = False

break

num += 1

if isalpha(c):

os.rename(filename, filename[num:])

num = 0

stop = True
>>
>>55460176
Wow thank you anon. I also didn't think of doing it the second way.
>>
>>55460364
What's with that excessive whitespace, Anon.
>>
>>55460224
>>55460231
>>55460249

Okay somehow the following code


while (i<n && scanf("%d ", &*intPtr) ==1){


intPtr++;
i++;


}

seems to work..
>>
>>55460387
The python effect. You make whitespace mandatory and suddenly it's everywhere.
>>
>>55460307

I don't know what you mean by precalculus, but analysis and, while we're at it, abstract algebra with linear algebra put your brain in the right place (only for it to be blown away in differential geometry and logic afterwards, lol).

But honestly, I didn't use them at all in my work. Still, mathematics really help with your thinking and, in my opinion, it's worth it just for that.
>>
Had a script that combined data read-in and processing in the same loop and it was a fucking mess, and then this morning in the shower I realized it wouldn't actually be that much memory to hold the whole data input file in memory, and I wouldn't kill myself on file read times anymore. It also makes the data processing so much easier too.
>>
>>55460409
>>55460387
Actually I don't normally write code like that, so I don't even know, ha.
>>
What happens if I don't put return 0 at the end of a simple function? Is it implementation based? I assume it's something that the user wouldn't see since there are no compile or runtime errors.

Also, should I kill myself if I make stupid mistakes like leaving the final character of a line outside of a comment so that I end up getting a compile error?
>>
>>55460632
>hat happens if I don't put return 0 at the end of a simple function? Is it implementation based? I assume it's something that the user wouldn't see since there are no compile or runtime errors.
0 is returned implictly if you omit it in main() as I assume is what you meant to ask.

>Also, should I kill myself if I make stupid mistakes like leaving the final character of a line outside of a comment so that I end up getting a compile error?
Happens to everyone.
>>
ey /g im willing to get serious into something this summer but haven't picked a project yet.

Thinking about django and get into back-end.
>>
>>55460696
Here is what I meant, I was referring to the inspace function.

#include <stdio.h> 
#include <stdlib.h>

int inspace (int deg);

int main (void)
{
int num_sp =5;
char c;

printf("Input and press ENTER when done\n");
for(c =getchar(); c ; c = getchar())
{
if(c != '\t' && c != '\n')
putchar(c);
if(c == '\t')
inspace(num_sp);
if(c == '\n') {
putchar(c);
break;
}
}
return 0;

}

int inspace (int deg)
{

int j;

for(j = 0; j < deg; ++j)
putchar(' ');
j = 0;

// return 0;
}
>>
File: Selection_036.png (541 KB, 1280x721) Image search: [Google]
Selection_036.png
541 KB, 1280x721
We got the vehicle physics going with Bullet Physics which is awesome, and a GUI (See the top left widget) and are working on the HUD and networking. I am also doing some refracting of the code. We also got some new assets, this project is getting interesting :^) Here is our repo for anyone interested:
https://gitlab.com/CollectiveTyranny/DMUX
>>
>>55460776
From the C Standard:

(C99, 6.9.1p12) "If the } that terminates a function is reached, and the value of the function call is used by the caller, the behavior is undefined."

The main function is an exception to this rule as if the } is reached in main it is equivalent as if there was a return 0; statement.
>>
>>55460824
Thank you very much anon. I will do my own research from now on instead of bugging you guys.
>>
>>55459652
Worst part? I actually did code this recently

#include <stdio.h>

int main() {
int i;

for (i = 1; i <= 100; i++) {
if (i % 15 == 0) {
printf("FizzBuzz\n");
}else if (i % 3 == 0) {
printf("Fizz\n");
}else if (i % 5 == 0) {
printf("Buzz\n");
}else{
printf("%d\n", i);
}
}

return 0;
}


:^)
>>
File: egkeuvbwekbej.jpg (23 KB, 385x385) Image search: [Google]
egkeuvbwekbej.jpg
23 KB, 385x385
>>55460856
>tfw I just remembered I have immunity cat protection
>tfw I keep falling for shitty b8
>>
>>55460364
You're like the retard in my plant that programs in C# once a year. He makes enough whitespace around functions to make sure only one is visible on the screen at any given time.
>>
>>55460776
A while loop would work better here.

while( c = getchar() != '\n' ) {
if( c == '\t' ) {
inspace(num_sp);
} else {
putchar(c);
}
}
>>
File: 1467153075011.webm (3 MB, 400x455) Image search: [Google]
1467153075011.webm
3 MB, 400x455
>>55460871
Here's an immunity cat for everyone else
>>
>>55460946
while( (c = getchar()) != '\n' )
>>
>>55460965
Right, missed that.
>>
>>55459652
Literally just made an educational video about fixing syntax errors, am I boned or left-alone?
>>
>>55460965
I love parenthesis so much
>>
>>55460946
Yeah I know it's messy. I designate a time in my day where I go back to "old" code and make it more "effecient". Thanks anyway.
>>
>>55461043
Show us the video anon, we'll be the judge of that.
>>
>>55461105
here you go

https://www.youtube.com/watch?v=ame2PH67gnk
>>
>>55459652

print "FUCK OFF BOOGEYMAN!"


t. started Python last night.
>>
http://www.lel.ed.ac.uk/~gpullum/loopsnoop.html
>>
>>55460856
>printf("FizzBuzz\n");
boogieman rapes you to death
>>
>>55461441
What's wrong with that? I tested it and it seemed fine.

Please enlighten me oh wise anon
>>
>>55461352
Using an old branch of python? The boogeyman will be after you for sure, anon.
>>
>>55461462
>>55461462
You're using the print formatted function without the use of formatting.

puts/fputs would do
>>
>>55461471
Not anon, but I state to the boogeyman:

"When the majority of the Python code that you use on your corporate system is running Python 3, I'll switch"

That'll keep him off for about ten years
>>
>>55461462
You already have statements that will print the components of the word.
Think about it.
>>
>>55461493
That's not technically wrong though; it can be used like that. I'll take your suggestion, but the boogeyman will have to satisfy his savage desires off of some other poor anon.

Plus, that immunity cat... >>55460963
>>
How do i into python lads?
>>
>>55461547
Just go to the documentation, and try things out.
>>
>>55461547
Codeacademy is a nice gentle start if you're clueless.
>>
>>55459573
Not programming related but this is the only relevant thread I could find, SQT hasn't been helpful
>>55459998
>>
>>55461621
You don't need any books to develop a hand cipher.
Just make some modifications to ROT13.
>>
>>55460776
You can give a function the return type "void" which means that it doesn't return anything.

void inspace (int deg) {
int i;
for (i = 0; i < deg; ++i)
putchar(' ');
/* nothing left or required to do. */
}
>>
File: zvCw1LK.gif (2 MB, 320x180) Image search: [Google]
zvCw1LK.gif
2 MB, 320x180
>>55459962
>mfw when this compiles
>>
>>55461493
>hey look, I'm an insufferable prick!
1) It's more consistent if you use only printf
2) It's easy to add formatted arguments if you need to
3) puts is confusing because it automatically inserts the newline; people reading the source might not know that without looking at the docs
4) GCC always turns printf("...\n") into puts("...")
You literally have no excuse for being such a shit head.
>>
>>55461674
>in the year of our lord C99+17
>space between identifier and opening paren
>two-spaces for indentation
>not putting variable declaration in the initialization expression of the for loop
>prefix increment
>omitting braces around a control structure
>putchar
>multiline comment notation used for a single-line comment
ritchie is spinning in his grave rn
>>
>>55461704
runs too ;)
>>
>>55461616
I'm not clueless, just a new language.

I actually did the code academy course when I was first getting into programming, but now I have to properly learn it for work

>>55461573
I think this is a good idea, read quite a lot of the documentation and also some introductory book on safari, but it doesn't help

I am trying out some basic control flow like

If arg do this
Elif do that

And it just keeps quitting on me, with no stack trace or anything

I must be doing something incredibly stupid but I don't know what
>>
File: lpthwbook.jpg (52 KB, 244x248) Image search: [Google]
lpthwbook.jpg
52 KB, 244x248
>>55461547
Learn Python the Hard Way
>>
>>55461769
>>space between identifier and opening paren
>>two-spaces for indentation
It's cause I hand-typed it into the code tags.

>>not putting variable declaration in the initialization expression of the for loop
It's a habit because I used to compile without -std=c99. It doesn't make any semantic difference and I think it looks better

>>prefix increment
Literally no semantic difference, a C++ habit.

>>omitting braces around a control structure
Not a significant enough body for it to be worth it

>>putchar
Just regurgitating what the other poster used. He doesn't know you're supposed to use
printf("%*s", n, "");


>>multiline comment notation used for a single-line comment
All my comments are multiline, unless they're used to block-out code. It's consistent that way.


Also
>giving this much shit about 5 lines of code
You must be a complete shithead in real life.
>>
>>55461808
Anything but this book.
>>
Haskell is shit.
>>
>>55461105
https://youtu.be/A__8Y8I3hNo
>>
I'm using pip to manage dependencies on a per project basis, isolating environments. In order to deploy, my project must be inside of a docker container, which loads the environment into a simulated operating system. Docker must be run in a linux distribution - so I use vagrant to deploy a virtualbox vm, wrapping the docker containers into a linux based operating system.

Version control. Dependency control. Environment control. OS control. Everything is monitored and kept under control. Code has changed. The age of deterrence has become the age of control... All in the name of averting catastrophe from . And he who controls the code... controls history. Code has changed. When the computer is under total control... Code becomes routine.
>>
DOES ANYONE HAVE A WIN10 MACHINE HERE?

If so, could you kindly check what syscall code kernel32.dll!WriteConsoleA is?
>>
>>55462161
shoulda used docker
>>
>>55462161
http://lmgtfy.com/?q=kernel32.dll!WriteConsole
>>
File: im_done.gif (2 MB, 250x188) Image search: [Google]
im_done.gif
2 MB, 250x188
>>55459573

>what does SMB stand for?
How the FUCK would I know? More importantly, why?!

>Do you know what DNS means?
Why are you asking me what Domain Name Systems MEANS instead ow what it DOES?

>what does the PAM abbreviation mean?
Why the fuck is me knowing that Pluggable Authentication Modules stands for PAM would be relevant to me being a developer?

I feel like I'm taking crazy pills!
>>
>>55461847
Why is so bad? It was recommended to me by a teacher back at uni
>>
>>55460088
>>55460127

Maybe a coordinate reference ? Maybe the next line has an "y" variable ?
>>
>>55462216
Zed just wasn't meant to write books.
>>
>>55462214
???
>>
>>55462250

Abbreviations can be googled in 10 seconds or less.

Asking for meanings of abbreviations does not a good interview question make.

But they keep asking those.
>>
Can somone help me?

I am trying to pass a function pointer to another class, but am running into difficulties. i cut out a lot of code, so tell me if I am missing something critica.

connection.hpp
connection_metadata{
public:
void setMessageCallback(std::function<void()> *message_callback){
m_message_callback = message_callback;
}
private:
std::function<void()> *m_message_callback;
};


data_stream.hpp
class data_stream{
public:
void init(){
//gets specific instance of connection class.
connection_metadata::ptr metadata = m_endpoint->get_metadata(m_connection_id);
//sets the callback function
metadata->setMessageCallback(&data_stream::message_callback);
}
void messageCallback(){
std::cout << "Test" << std::endl;
}
};


I however get the error:
Cannot initialize a parameter of type 'std::function<void ()> *' with an rvalue of type 'void (data_stream::*)()'
I can't figure out how to fix this, or even if I'm doing it right...
>>
>>55462214
if you dont know that stuff I wouldnt even hire you as an intern for desktop support

youll never be a developer.
>>
Is there any way to find a udp client's MTU without pounding them with progressively larger/smaller packets?
>>
File: 1440445784050.jpg (92 KB, 320x308) Image search: [Google]
1440445784050.jpg
92 KB, 320x308
>>55462349

I have no idea what SMB stands for and I'm a successful senior developer at Amazon.

I could google it right now but there is NO POINT.

Shows how much you know.
>>
>>55459652
(def board
;;returns a new reversi game board
;;with the first 4 pawns already placed
(-> (repeat 0)
(as-> brd (take board-dimension brd))
(vec)
(repeat)
(as-> brd (take board-dimension brd))
(vec)
(assoc-in [3 4] white)
(assoc-in [4 3] white)
(assoc-in [3 3] black)
(assoc-in [4 4] black)))

reversi board in clojure. Am I safe?
>>
>>55459652
cdef fib(int n, a = 0, b = 1, int i = 0):
if n == 0 or n == 1:
return n
if i + 1 == n:
return b
return fib(n, b, a+b, i + 1)

cdef int i = 0
for i in range(1, 101):
print(fib(i))


I made this last thread
>>
>>55462363
Baaaaaaaahahahahahahahahahahahahaha
>>
>>55462338
class connection_metadata {
public:
void setMessageCallback(std::function<void()> message_callback)
{ m_message_callback = message_callback; }

private:
std::function<void()> m_message_callback;
};

class data_stream {
public:
static void message_callback() {
std::cout << "Test" << std::endl;
}

void init() {
//sets the callback function
metadata.setMessageCallback(&data_stream::message_callback);
}

private:
connection_metadata metadata;
};


Honestly, I'd rather templatize it instead of using std::function.
>>
>>55459652
main = putStrLn "Fuck off boogeyman
>>
>>55462452
pls
>>
>>55462363
>Tanx you beddy mush for to calling amwazon web sappot my name is Rajeesh senior dewelopa ad amwazon how may I be dilectink you savise today?
>>
>>55462476

hahaha, yeah, we do have a lot of indians in premium support

God their english is horrid.
>>
>>55461847
why the fuck this >>55461808 motherfucker is still teaching python 2.7???? is it the fucking 2010??
Yes, I'm mad.
>>
>>55462447
why? just preference? Also thanks so much. Didn't realize my callback function had to be static.
>>
So if I were to write an operating system that fit entirely on the CPU cache, it would be as fast as it possibly could be, right?
>>
If i'm making a script for my game, how should I go about defining media?

definesprite( "./data/spr_test.bmp", "spr_test", 16, 16, 4, 4 )


this is what i'm thinking, with each parameter being the following

>1: path to sprite sheet file
>2: name of sprite sheet to index
>3: width of each sprite
>4: height of each sprite
>5: how many rows in the sheet
>6: how many columns in the sheet

seems like alot, but then again I don't know how other games do it; I have looked at the .CON files in duke nukem 3D in the past.
>>
>>55462672
Probably unless you pulled off fitting the whole thing in the registers only
>>
Pretty happy. Got a somewhat decent A* for a shitty "maze" generator I made working
>>
>>55462701
Oh, that sounds even better.
How do I find out how many registers I have on a given CPU? Intel's website doesn't give me quite that much detail.
>>
>>55462722
What does that even mean?
>>
>>55462760
A* is a pathfinding algorithm, so I presume he wrote a program to solve a maze.

>>55462722
post code plz
>>
>>55462737
I was joking, that would be impossible.
x86_64 would give you like 16 general-purpose registers to work with, plus some segment registers.
>>
>>55461502
Enjoy being left behind in less than 4 years, also majority of all relevant libs run with 3 so yeah.
>>
>>55462760
Basically I made a thing that draws a maze with a random start and goal point. In order to validate the goal point is reachable from the start position I implemented a search algorithm, A*, to find a working path to it. The reason I have maze in quotes is cause it's not a true maze, more just a randomly plotted set of walls that can end up blocking either the start and end points.
>>
>>55462722
Does it do better than DFS?
>>
File: 0x2002.png (29 KB, 677x342) Image search: [Google]
0x2002.png
29 KB, 677x342
>>55462191
>lmgtfy

I know what WriteConsoleA is. I was just trying to find out if W10's version has the same syscall number as its W7 counterpart (pic related).
>>
>>55459573

I tried to learn programming with CPP. Got into it, dropped cause school, never picked it up.

Now I want to lear either web development, or programming (just enough to know I'm not getting fucked over when I have to hire someone).

I was thinking on picking up Objective C, since it falls in line with what I work on.

Thoughts?
>>
>>55462880
>Objective C
Why not Swift?
>>
>>55462880
What is your job?
>>
>>55462790
It's supposed to be separated into maze.py and main.py, I was trying an "OOP" approach. Let me know if there's something I should be doing that I'm not! Or if there's some way I could make it faster.

http://pastebin.com/qQRtbm42
>>
>>55462693
looks fine to me
>>
>>55459652
Uses this one to rename all the files in my porn collection. As a bonus it also removes exact duplicates. First time I did something in python.
#!/usr/bin/env python

import os
import time
import sys
from hashlib import sha1

# calculates the sha1 hash for a file
def hash(path):

# open file in [r]ead [b]inary mode
file = open(path, 'rb')

generator = sha1()

# read file in blocks
while True:
data = file.read(8192)
if not data:
break
generator.update(data)

return generator.hexdigest()

def main():
# get all files (excluding folders) in current directory
files = filter(os.path.isfile, os.listdir(os.curdir))

for file in files:
name, extension = os.path.splitext(file)

# ignore this script
if file != os.path.basename(__file__):

# keep only the first 8 symbols to get a short filename
newName = hash(file)[:8]

newFile = newName + extension
os.rename(file, newFile)
print file + ' -> ' + newFile

if __name__ == '__main__':
sys.exit(main())
>>
>>55462846
I'm not sure, I think it'd be interesting to test it though. I use my pi for feeling the impact of run time. I did a 1000x1000 on it and it's been like 20 minutes
>>
Trying to compile the C driver for MongoDB (github.com/mongodb/mongo-c-driver), which tells me to compile it with 64bit flag. However, it gives me linker errors when I try to use it in a project with Visual Studio and I can't build a project that uses the .lib files from the C driver build.

On the other hand, compiling it as 32 bit results in succeeding builds.

Why is this /dpt/? Can I compile a 64 bit solution?
>>
Spent the better part of 6 hours working on SQL queries to rank the last 7 days shows in order of popularity, and show the most popular shows on the index page.
Took me that long to realize that it looked cluttered and stupid, so I deleted it all.

That's it for today.
>>
>>55461502
Hello Zed Shaw!!!
>>
>>55459652
https://github.com/randombit/botan/pull/495/files
>>
>>55459652

Uhhh... have a Rakefile.

http://pastie.org/10901489

And then I shoot the Boogeyman while it's distracted reading the code. Several times. With wax slugs for maximum damage.

>>55463163

Presumably, the libs are 32 bit. You can't link 32 bit and 64 bit code.
>>
>>55459573
>Load effective address
Well fuck me, you might as well have a built in instruction for building entire web servers.
>>
>>55463300
I probably should've been a bit more clear. Using cmake I instruct the driver to build with the Win64 compiler (Visual Studio 14 Win64), which should (I think?) result in 64 bit libs. I can't seem to compile an actual project using these libs. However, if I compile them as 32 bit (Visual Studio 14, notice no Win64) I can compile the project I link them in as well.
>>
>>55463304
That's fucking nothing, Pajeet. Is CS really that bad in your country that you think "load effective address" is a complicated CPU instruction?
>>
test
>>
>>55463400
Take it ez m8, I'm just memeing.

4 real tho I've only seen LEA in LC3, and that's a meme.
>>
why
>>
>>55463494
Muslims and misogyny.

t. Indian
>>
>>55463450
Why is LC3 a meme? I liked it
It was a solid introduction to ASM desu
>>
>>55463509
Personally I thought that MIPS was way better. My college has its own derivative of MIPS with less instructions, but I thought it was easier. Maybe it's cause I actually bothered to learn it by myself and not rely on someone else for the explanations and answers.
>>
>>55463450

I've only seen it in x86, since it's not exactly a RISC-y instruction. It's rather useful though, since it's basically a shift and add instruction in one.
>>
I created a group for my linux service. Then i changed the project directory's group recursively to that group name.
I added a daemon to that group. now when I try to read/write those project files there's still a permission error.

is there a startup guide on how this works? what am i missing?
>>
>>55463552
Three-input add is RISCy. ARM has shift and add. LEA can be done in one or two cycles and doesn't even read or write memory. Integer multiply is more CISC than that, let alone any SIMD or FPU instructions.
>>
>>55462214
>what does SMB stand for?
Maybe they wanted to know if you gamed as a youth because gamers make for good programmers?
>>
>>55463530
They thought MIPS was too hard so they created a version with less instructions?
Holy fuck I literally don't even.
>>
>>55463552
>lea is not RISC-y

But it's mostly used as 3-way ADD. How is that not RISC-y?

Try XLAT or MOVNTI.
>>
Let's say I have a console headless application running in the background, and I'm on linux. How do I shut it down properly? I don't want to brutally kill the process. I want to send it a message/signal that would trigger an interrupt or whatever, so I can close database connections etc and shut everything down.
>>
>>55462904
Dunno, read about it... is it really DA FUTUR?

>>55462908
I usually do advertising, but I'm now in corporate communications. More often than not some shithead clients thinks their whole business will be now profitable just because they get an app. So I have to hire someone to develop it (small, indy teams for small projects) so I would like to speak to them on the same level, and avoid asking too much/impossible or getting shit excuses (I had a guy literally tell me he would need an extra week cause his IDE got hacked.)
>>
>>55463981
No, I wouldn't say that. Just a version of MIPS so that we can learn processor design and stuff.
>>
>>55464120
>(I had a guy literally tell me he would need an extra week cause his IDE got hacked.)
no amount of knowledge on your part is going to avoid having issues like that
the only way to prevent that is to build up a list of good people over time and only use them
>>
>>55464013
send kill 15
if it doesn't work send kill 9
>>
>>55464247
can I react to that kill signal in my application? so for example I can update log file with shutdown date and time and so on
I want to use it in a small application that basically reads data from GPIO on rpi
>>
>>55459598
Do arrays wrap around? no.

It's an iterator
>>
>>55460088
x is meaningful here:
id :: a -> a
id x = x
>>
>>55464362
> Do arrays wrap around? no.
>>> a = [1,2,3]
>>> print a[-1]
3
>>
>>55464293
>can I react to that kill signal in my application?
yes
http://www.yolinux.com/TUTORIALS/C++Signals.html
>>
>>55464394
perfect, thanks
>>
>>55459652
I did this a while back. It's a simple Tic-Tac-Toe game in Python. I know I could reuse code in the main function and blablabla, but I'm lazy. Code doesn't fit in post. pastebin.com/fN6fqEGh
>>
>>55462693
bumpu desu
>>
can you guys give me a cool project to work on?

i'm not a beginner so it can be somewhat complex
>>
>>55464717
make a basic operating system
>>
>>55464717
make a roguelike
>>
>>55464771
I've actually been considering doing this for a while now. I tried years ago when I was a shit programmer, but I could probably finish one nowadays.

>>55464735
Another thing I've had on a sort of programming bucket list. Thanks for reminding me.
>>
>>55464798
>I've actually been considering doing this for a while now. I tried years ago when I was a shit programmer, but I could probably finish one nowadays.
I'm working on one right now. I've got dungeon generation done but I'm really hung up on how to design the combat system.
>>
>>55464826
Yeah, the big problem with making games isn't really the technical challenge, but making them fun to play.
>>
>>55464717
Make a Haskell compiler in an assembly language of your choice.
>>
>>55460364
You made it way harder than it needed to be.

import os

for filename in os.listdir('.'):
for character in filename:
if character.isalpha():
os.rename(filename, filename[filename.index(character):])
break
>>
>>55459604

Why are anime posters always shitposters with shit bait?

Are you really that desperate for attention?

If you're suffering from depression your should seek help instead of trying to shit up an anonymous image board in a desperate attempt for responses and validation
>>
uncurry (++) . partition (9 /=)
>>
>>55460364
>>55465061

You are both overengineering. And >>55465061 renames too much.

shopt -s extglob

for f in *; do
mv -f "$f" "${f/+([^[:alpha:]])}"
done
>>
>>55465145
What did he mean by this?
>>
>>55465061
>tfw ur character is beta
>>
>>55465145
stop trying to create a virus for starving rajeets
>>
>>55465226
>tfw betanumerical
>>
>>55465241
betanumerical character uprising when
>>
>>55465191
What language is this?
>>
to whoever this /python fag/ is... go away.. i am disgusted that you would pick such language yet go to this board... made for REAL coders......... java can make minecraft mods.. python cannot.. checkmate
>>
>>55465061 here

>>55465191
What do you mean by >renames too much<?
>>
>>55465277
bash

>>55465304
sorry, read it wrong
>>
>>55465277
bash

>>55465303
kek
>>
>>55465277
spotted the winfag
>>
>>55465339
Yeah, sorry :^).
>>
File: 129317623_6aef10a328.jpg (103 KB, 500x335) Image search: [Google]
129317623_6aef10a328.jpg
103 KB, 500x335
Hi /g/. I had a question that didn't feel deserving of its own thread: I'm a programmer on my last year of college with experience in JavaScript, C++, and very recently C#. I was wondering how difficult it would be to comprehend and write code for media players, primarily music players reading mp3 and FLAC? Would any of the above listed languages for appropriate to handle that? Where could I find documentation relevant to this? Any help on where to start would be greatly appreciated. Thanks!
>>
>>55465418
What do you mean by that? Pick a UI library, an audio library and go.
>>
File: 1460932836643.png (82 KB, 461x660) Image search: [Google]
1460932836643.png
82 KB, 461x660
Anybody got more of these? They jiggle my sides.
Also fuck WPF so much.
>>
>>55465209
It puts all of the nines at the end of the list

f :: [Int] -> [Int]
f = uncurry (++) . partition (/= 9)

f [1,9,2,9,3,9,4,9] = [1,2,3,4,9,9,9,9]
>>
>>55465418
Most music players won't let you modify functionality with code, but I'm sure some do. The language could be just about anything.
>>
>>55465526
What the fuck
>>
File: 1423422463037.png (29 KB, 702x663) Image search: [Google]
1423422463037.png
29 KB, 702x663
>>55465497
A fucking arsenal mate
>>
>>55465458

I'm really disappointed with currently available options for media players and instead of taking a hundred hours to master Foobar customization, I was curious as to how difficult it would be to simply program my own. The actual encoding is what I feared might be difficult to work with. Are you saying I can just download a package for Visual Studio or something and integrate it with my code, and voila, I'll have MP3 support?
>>
File: 1423429601017.png (37 KB, 694x732) Image search: [Google]
1423429601017.png
37 KB, 694x732
>>
File: 1423925335625.png (32 KB, 694x446) Image search: [Google]
1423925335625.png
32 KB, 694x446
>>
>>55465581
libraries
learn what they are and appreciate them
>>
File: 1425473635288.png (38 KB, 890x670) Image search: [Google]
1425473635288.png
38 KB, 890x670
>>
File: 1425473695874.png (42 KB, 916x753) Image search: [Google]
1425473695874.png
42 KB, 916x753
>>
>>55465555
partition PRED LIST = (LIST1, LIST2)
where LIST1 contains every 'x' from LIST where PRED(x) is true, and LIST2 contains all of the other 'x's

/= means "not equal to" (most programming languages use != instead, but in haskell it's /=).

(9 /=) is short for (\x -> 9 /= x), which is a predicate that tells if a number is not equal to 9. This short-hand trick happens when you don't supply a value to a side of an operator, e.g.
(1+) has no right hand, so it becomes a function that adds 1 to its argument
(*2) has to left hand, so it becomes a function that multiplies its argument by 2.

We supply this '(9 /=)' predicate to our partitioning. Thus the input gets divided into two lists (l1,l2) where l1 is all of the numbers that aren't 9, and l2 is all of the 9's

(++) appends two lists together. uncurry modifies the (++) function so that it accepts the pair (l1,l2) as it's parameters, thus becoming l1 ++ l2, which is all of the non-nines, and then all of the nines.
>>
File: 1443819080780.png (36 KB, 1515x663) Image search: [Google]
1443819080780.png
36 KB, 1515x663
>>
>>55465614

I know what libraries are in reference to web design. My school doesn't teach anything like JQuery, but realizing how woefully unprepared the web design kids were at graduation, I decided to drop that and go comp sci. Web design libraries have immense support and are generally simplified to use. I haven't dealt with any C++ / C# libraries.

I guess I should have started my search by googling "media codec libraries," fair. I'll do some more research starting here.
>>
File: 1443819552609.png (62 KB, 850x800) Image search: [Google]
1443819552609.png
62 KB, 850x800
>>
File: 1457040221084.png (154 KB, 3000x3000) Image search: [Google]
1457040221084.png
154 KB, 3000x3000
>>
>>55465640
Thanks man, that explains some of it for me.

Where does the actual list argument go though?
>>
>>55465634
where did you find this
>>
>>55465706
here
>>
>>55464389
that's python though
>>
>>55465654
how are you supposed to do this?
>>
>>55465746
regex or loops
>>
>>55465746
There are several ways, but most languages have a "is alphabet" or "is num" function.
If you really want to go the whole way, you could use regular expressions/Finite state machines to check the whole string.
>>
>>55465746
idk how to do it in pyshit but in C# you literally just
string input = Console.ReadLine();
int num;
bool result = int.TryParse(input, out num);


If the string is parsed as an int it also returns true. Otherwise false.
>>
>>55465685
The composition operator makes the argument kind of "hidden". Notice how I declared it
f = ...


(f . g)(x) is the same as f(g(x))
So
(uncurry (++) . partition (9 /=)) (x)
is the same as
uncurry (++) (partition (9 /=) x)

So
f = uncurry (++) . partition (9 /=)
is the same as
f x = uncurry (++) (partition (9 /=) x)


It's a neat/dumb trick that makes your code smaller and less readable, and Haskell programmers are obsessed with it.
>>
>>55465746

user_input = raw_input()
if user_input.isalpha():
print 'blablabla letter'
elif user_input.isdigit():
print 'blablabla number'
elif user_input.isalnum():
print 'blablabla number letter'
>>
>>55465827
>>55465803
>>55465789
i don't see how saying "just don't implement it yourself" is a valid critique of a csci meme, obviously it looks terrible but maybe the point was that she was trying to make her own implementation
>>
>>55465805
Thanks man. Does it make any difference to the compiled code if you write it the way it was originally written? It seems like it just makes it more confusing to me.
>>
>>55465877
No difference, only thing different is academicucks will throw a fit at you.
>>
>>55465680
make a separate thread, fag
>>
>>55465875
Her implementation doesn't account for Roman numerals
>>
>>55465909
I'm done
>>
>>55465875
Maybe you should learn a thing or two about ASCII.
'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z'

But even then, that doesn't generalise to non-ASCII letters.
Using a language's "is alpha" function is a much better idea.
>>
Can C compose functions?my coworker Kris laughing at me because he says it can't
>>
>>55465875
This code doesn't have programming logic. It repeats itself stupidly and doesn't even work properly. If your input is "9Hello world" the output will be "Nice number!", because it checked "9" was in the input and it stopped. Also, in most cases you shouldn't try to create your way to do things if the language you're using gives you a simple and fast way to do the same thing.
>>
>>55465967
By "doesn't have programming logic" I mean doesn't follow programming logic.
>>
>>55465958
Do you mean simple use like
result = f(g(x));

or actual composition like
type3 f(type2 x);
type2 g(type1 x);

type3 (*f_of_g)(type1) = g . f

?

C can't do the second one directly.
You have to create a new function
type3 f_of_g(type 1 x)
{
return f(g(x));
}
>>
>>55466061
#define f_of_g(x) f(g((x)))
>>
>>55466151
That isn't really any different. There is still no actual "compose function" in C.
>>
>>55465773
>>55465789
why the fuck would you do that?

>>55465803
try:
int(raw_input())
print("A number")
except:
print("Not a number")
>>
>>55466219
If you're not using a slow, shitty language like python.
>>
>>55466237
you sound mad. why are you mad bro?
>>
Should I set a pointer to NULL after I delete it?
>>
>>55466332
absolutely livid my dude
>>
>>55466342
>delete
that means you're using C++
>pointer
No.
>>
Does anyone have experience in machine learning? I've got a side project that I've been working on. And I've finally been able to collect and format the data. Now I'm ready to use scikit learn to try and do some predicting. However I'm running into problems on how to go about feeding my data into a SVM.

Basically I'm trying to take a group of entries, where each entry has a certain amount of features. And compare all the entries in that group and determine which are the top 2.
Now, the problem is one entry might be good in one group but terrible in another. I've heard I should use some ranking models but there are not a lot of good explanations or I'm missing them.

Any help would be much appreciated.
>>
>>55466362
I have seen examples of other people doing it which confused me.
>>
>>55466403
I meant don't use raw pointers in C++.
>>
>>55466061
I think the second. He laughs at me because he chooses not to use C, but I prefer C because it has less overhead when one wishes to commune with the machine directly.
>>
File: living_on_the_edge_w1.jpg (560 KB, 1920x1200) Image search: [Google]
living_on_the_edge_w1.jpg
560 KB, 1920x1200
>>55465497
>mfw compiling several software from master every single day
>>
>>55466513
No function composition is hardly something to complain about. It's nice and all, but it's hardly a killer feature.
The use cases for function composition are pretty limited. It's not very often when you have two functions with compatible signatures and you use them together so often that you need to compose a third function from them.
>>
I hate my job.

The actual work is tedious and not programming at all. The contributions I make are never noticed, and when they are they're immediately shut down despite working perfectly and only taking a single command to run. Meanwhile, the guy who started a week after me created something that barely functions and takes 20 minutes to set up every time you re-open your terminal, and everyone loved it so much he's basically my boss now. It's only been four fucking weeks!
>>
>>55466710
Then why'd it surpassed your solution, think about it.
>>
>>55466752
His script is supposed to automate asking an AI questions at roughly the same speed a human can.

The first script I made meanwhile automated teaching the AI the answers to those questions, and the reason it's never getting used again isn't even the fault of the script. The AI had an entire system built into it that overrides the normal questions and answers and causes it to crash on certain questions
>>
>>55466838
You shouldn't have made it crash, anon
>>
File: tags.png (99 KB, 1291x570) Image search: [Google]
tags.png
99 KB, 1291x570
I think I got his by the bad code boogyman what am I doing wrong?
>>
>>55466919
I didn't design the system, nor did I break it
>>
>>55466962
try not enclosing h1 tags
>>
>>55466962
why <p> around <h1>?
>>
>>55467029
>>55466986
Thanks man. I had them backwards for some reason.
>>
>>55466962
you're never going to make it, Josh
>>
>>55466962
Sorry to tell you, but Codecademy won't really help you.
Thread replies: 255
Thread images: 36

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.