[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: 35
File: DPT.png (389 KB, 934x1000) Image search: [Google]
DPT.png
389 KB, 934x1000
Old thread: >>54327009

What are you working on /g/?
>>
I have a 2d grid, and an element on it. When the mouse is clicked and dragged, I want to move the element the same way the mouse was moved. In other words, you control the element by dragging the mouse, but it doesn't have to be on top of the element.

I would have an offset x and y, and then on click I would set that to the click's x and y, and then on each drag frame I would set set offset x and y to the mouse location x and y, the element's x += offset x, and element's y += offset y, right?
I would post code but its shitty bloated Java code and I don't think it would help.
>>
File: ArtOfComputerProgramming.jpg (108 KB, 349x492) Image search: [Google]
ArtOfComputerProgramming.jpg
108 KB, 349x492
I'm currently reading pic related.

I don't fully understand the target audience for this. He goes super in-depth into mathematical proofs and induction before he even touches assembler for a fantasy processor.

I'm currently on the exercises in the induction section 1.2
>>
File: 1462131699134.png (90 KB, 963x866) Image search: [Google]
1462131699134.png
90 KB, 963x866
Hey /dpt/,
We've started a slack group with the aim of organizing the studying of books related to CS/math/philosophy.
This Sunday we finished past projects and are starting some new ones, namely:
1)SICP
2)Networking
3)Goedel, Escher, Bach
4)Set Theory
5)Logic II
https://docs.google.com/spreadsheets/d/1A_zbRf7YoiY_454INuLXEuSuW3ro0rZtaGJtnIb4XNw here's the schedule.
If you're interested, then leave your email here (making a fake one is recommended, needed only for an activation) and I'll send an invite.
>>
>>54334106
>Programming is easy, isn't it?
>No, it's not!!!!! here, you have to read this book to learn it....
>Oh my god, it must be really hard!!!! im impressed!!

that's why he wrote those books
>>
>>54334087
>>54334097
finally!
thanks you FagChan!
>>
>>54334119
meh, ill join. [email protected]
>>
>>54334157
sent ;)
>>
File: 1414389577537.jpg (32 KB, 500x330) Image search: [Google]
1414389577537.jpg
32 KB, 500x330
https://www.youtube.com/watch?v=QM1iUe6IofM

Daily reminder that OOP is shit.
>>
Any QT experts out there.
For some reason I keep getting the error
>No such slot mytimer::MySlot(a)
and 'test2' doesnt show up.
Im really new to QT and its been a year since Ive programmed so be gentle
void mytimer::hope(Dialog& a)
{
a.line="test1";
connect(timer,SIGNAL(timeout()),this,SLOT(MySlot(a)));
timer->start(1);
}


void mytimer::MySlot(Dialog& a)
{
a.line="test2";
}
>>
Why can't I connect to my server

var express = require('express');
var app = express();
var http = require('http').Server(app);

var GetAddress = function() {
var os = require('os');
var ifaces = os.networkInterfaces()

for (i in ifaces) {
for (j in ifaces[i]) {
if (ifaces[i][j].family === 'IPv4' && ifaces[i][j].internal === false) {
return ifaces[i][j].address;
}
}
}
}

http.listen(3000, '0.0.0.0', function() {
console.log('listening to '+GetAddress()+':3000');
});
>>
>>54334274
GetAddress() isn't guaranteed to return anything

and apparently it doesn't
>>
/g/, what's the best Scheme implementation?
>>
>>54334332
your own
it's not hard
>>
>>54334320
No, it's definitely returning something because 'listening to x.x.x.x:3000' is printed to the console
>>
>>54334332
Racket is non-standard in a bunch of ways but it's very high quality. Personally, I use Guile because it's GPL and it's as embeddable (if not more so) than Lua.
>>
Jimmy Birer respond to my messages you nonce
>>
I wish I could program but I'm so freaking freaked out about where to start I just panic and surf the web instead.
>>
>>54334332
Common Lisp
>>
>>54334452

Implement minesweeper in Java

Thank me when you have 120k/y job.
>>
>>54334452
basic programming methods using java 106A
https://www.youtube.com/playlist?list=PL84A56BC7F4A1F852
Programming Abstractions using C++ 106B
https://www.youtube.com/playlist?list=PLFE6E58F856038C69
>suggest you do both
also any book with "Head First" in the title
>>
Is an adder more accurately represented as (((A∨B)∧¬(A∧B))∨C) ∧¬(((A∨B)∧¬(A∧B))∧C), carry (A∧B) ∨ (((A∨B)∧¬(A∧B))∧C) or ((A⊻B)⊻C), carry (A∧B)∨((A⊻B)∧C)?
>>
>>54334452
join us for SICP
>>54334119
;)))
>>
>>54334452
read C Primer Plus by Stephen Prata, or C Programming, A Modern Approach by somebody else
>>
programming is hard = false
learning a language is hard = maybe, but doable
once you know a language you just speak it. or write it. see? i'm doing it right now. voila!
no different than learning spanish
>>
File: 1398031016227.gif (982 KB, 320x287) Image search: [Google]
1398031016227.gif
982 KB, 320x287
>graduating college
>about to do interviews for software dev jobs

how do I git gud at interviews senpai?

I know data structures, OOP, C, and SQL but I swear I know I will be asked a basic fucking question like doing C addition using bitwise operators and I will panic.

do interviewers hate when the interviewee admits he doesn't know after attempting the problem?

I have only done 1 job designing a website using Codeigniter so my resume coming out of college isn't the best.
>>
>>54334551
Cracking the Coding Interview is full of a bunch of great exercises that will sharpen you up. I've only done the first few chapters but they're great.
>>
>>54334531
>programming is hard = false
proper, non-shit programming is hard to the average person
>>
>>54334588
this isn't up for dispute, he set the variable to false.
>>
>>54334612
i like you, my guy
>>
I want a variable of a class to be an object. Like the reference to the object.
How do I go about doing it. Do I just say in the header

rectangle& var;
>>
>>54334119
[email protected]
Already working on SICP
>>
>>54334654
sent ;)
check in with progress
if you could help beginners, that would be good too
>>
>>54334652
did you try it?
>>
Learning Forth

(works in gforth with a vt100 or compatible)
: bound ( a -- a ) 4 cells + ; \ finis
: dir ( a -- a ) 2 cells + ; \ x y dx dy h w
: init ( n n a -- a ) rot tuck ! cell + tuck ! cell + ;
: init ( -- a )
6 cells allocate throw dup
rows 2 / cols 2 / init 1 1 init rows 1- cols 1- init drop ;
: reflect ( a -- )
dup @ 0= if 1 swap dir ! else dup dup bound @ swap @ =
if -1 swap dir ! else drop then then ;
: reflect ( a -- ) dup cell + reflect reflect ;
: move-xy ( a -- )
dup @ over dir @ + over ! cell + dup @ over dir @ + swap ! ;
: step ( a -- )
dup dup dup reflect cell + @ swap @ swap at-xy
move-xy [char] # emit ;
: steps ( n -- )
page init swap 0 do dup step 10 ms loop
dup 6 erase free throw ;
: until-key ( -- )
page init begin dup step key? 10 ms until
dup 6 erase free throw ;


>>54334588
Nope, they just need to learn the right languages. I'd say after the average person has picked up 4 languages, the'll understand how to write at least working code that's better than most java/python kids.

>>54334551
Learn another two languages that are as far from the ones you already know (Haskell/Scheme and Forth recomended) and complete the tasks you think you would be given in each. You can also prove you know how to solve a problem without programming if you can see problems with the task (e. g. the tasks requires bignums due to the range exceding the 64 bit integer size).

>>54334452
Haskell is good if you are fine with mathematics (it's nice even if you're not a math major).

Forth & Scheme are best (ex mea sententia) as they are closer to the machine but are far enough form it to get stuff done in. They also focus on extending them towards your problem domain rather than the C approach of throw more libraries at it.

>>54334332
Chibi-Scheme is quite nice if you like light weight scheme implementations.
>>
my compiler has so many boners right now!
https://www.youtube.com/watch?v=GZIvyi_kO40
>>
>>54334848
>codebabes
I like where this is going
>>
>>54334848
>java
>native apps
I don't understand android, but - really?
>>
>>54334848
she shoulda have been cast as the new Supergirl on CBS, but we got one as flat as Flockhart...
damn feminists
>>
>>54334848
fap or code?
fap or code?
fap or code?
ARGH!!!
>>
i have the following snippet of code which i dont quite understand, could someone tell me whats going on here?
Operation op = (Operation)input;
result = op.Do(flow);


now this is the definition for class Operation
public abstract class Operation : IFlowOperation {
public abstract Object Do(ProcessFlow flow);
public abstract Object Output(Object result);
}


there are 3 different classes that override this and all do slightly different things on the Do(ProcessFlow flow) method, how exactly does this code work? i cant see how its choosing one of the possible classes over the other.

example of other class that inherits from Operation
public class OpExecute : Operation {

public int count;

public OpExecute(int count) {
this.count = count;
}

public override Object Do(ProcessFlow flow) {
flow.Execute(count);
return null;
}

public override Object Output(Object result) {
return null;
}

public override string ToString() {
return "execute " + count;
}

}
>>
>>54334848

That chick is like a 6/10 also those glasses are so fucking dumb take them off or replace them.
>>
>>54334908
she takes them off as she undresses as the series continues
>>
>>54334916
Seriously? That's really sad...
>>
>>54334898
are you serious? I'm not aroused at all by that

there need to be at least SICP, TAOCP and K&R on her shelf before I'm into it
>>
>>54334937
check the channel
multiple language tuts
multiple playlists
new vids coming out regularly, i think?
>>54334937
maybe they'll make 'code studs' for you, pole smoker
>>
with sed

I have two patterns with things that have characters that escape.

In bash you can get around this by echoing as "$var1"

Now for sed,

I want to replace the string var1 with the string var2"

I've been trying to do

sed -i "s/'$var1'/'$p2'/g" file


but it doesn't work

Any ideas?
>>
>>54334916

Thank god.
>>
>>54334848
wtf that's so stupid and cringeworthy
>>
>>54334948
hey just because I suck dicks doesn't mean I don't mind me some tiddies when the time's right
>>
>>54334959
shaddup femanazi!
let him be, he done good
>>
>>54334933
i checked and yup she has them off in the 2nd and 3rd vids
>>
extern in C works like 'pubic static final' in java?
>>
>>54335031
"no"
>>
>>54335031
none of those things have any meaning in C
except for static but it doesn't mean what you think it means
>>
>>54335053
whats the difference then slut
>>
I wait to commit until midnight so i get internet points

also star my repos
>>
>>54335058
"extern" means "this symbol (variable/function) is defined somewhere else"
I have no idea what "pubic static final" actually does in Java
>>
>>54335058
>RTFM
found it on the first page while searching... learn to searx.me
>>
>>54335071
public means accessible from anywhere else in your code regardless of package or hierarchy

static means member of the class not an instance of the class

final means you can't reassign the reference

you can still mutate it though... lol
>>
>>54335087
C doesn't have any of those things
>>
>>54335087
>you can still mutate it though... lol
Not every language can be as thought out as Rust
>>
File: Connect4.png (32 KB, 701x485) Image search: [Google]
Connect4.png
32 KB, 701x485
Just made Connect4 in Assembly. Shit sucked, but it was kind of fun in a way.
>>
wew lads, start a paid internship tomorrow as a code monkey

any advice?
>>
>>54334678
Yeah and it didnt work
>>
>>54335116
nice

might do this desu
>>
>>54334959

Triggered?
>>
does anyone have experience with android programming mainly using android studios? how do you use the debugger wth so many files you have to step into. what is a good read so I can understand whats going on
>>
>>54335150
if you're gonna do something like that at least don't have shit tons of sexual references, keep it "clean" with the sexual attractiveness of the presenter being implicit

read some freud or something if you lack this common sense
>>
>>54334119
[email protected]
>>
File: dehydrated_pepe.png (729 KB, 697x603) Image search: [Google]
dehydrated_pepe.png
729 KB, 697x603
>get out of classes, finish exams
>start working on personal projects and looking for jobs/internships for the summer
>made the mistake of telling my friends and they ask me everyday to get on them with skype and play vidya with them, hang out, etc.
>also want me to keep working on the D&D campaign I ran for them last summer
>always accept because I'm a weak beta
>no time to work on personal projects

normiedom sucks, I can't believe I wanted friends
>>
>>54335275

It's clearly just clickbait. I find it repulsive too but this kind of stuff appeals to a lot of people out there who find it quirky
>>
>>54335288

start a company with your friends
>>
>>54335288
>playing games online
>normie

in what fucking world do you live in? most normie go out and do shit everyday in the real world
>>
>>54335275
SJW
go back to
>>>/pol/
>>
>>54335320
shill
go back to
>>>/leddit/
>>
>>54335288
Sick blog you faggot manchild
>>
>>54334848
What the fucking fuck?!
>>
>>54334119
[email protected]
>>
>>54334899 anyone? im having real trouble figuring this out
>>
File: 1461787163226.gif (81 KB, 182x249) Image search: [Google]
1461787163226.gif
81 KB, 182x249
>>54335275
>read some freud
>2016
>>
File: working.png (686 KB, 977x434) Image search: [Google]
working.png
686 KB, 977x434
I procrastinated SICP so hard that I wrote a program to help me take notes on the lecture series. When "save" is clicked, it checks if a directory for that lecture exists. If it does, then it saves the notes in to a jekyll compatible mark-down post. If the directory doesn't exist, it creates it and saves the file.

How does it look?
>>
>>54335372
>tfw cs meme
>tfw spent 4 years painstakingly learning c
>tfw all the programming jobs are java or python or javascript
>tfw the best language in the world is dead, replaced by meme languages
>>
>>54334899

can't tell you what it does without the definition of ProcessFlow my friend
>>
Thoughts on int 80h?
>>
>>54335407
>C
>the best language in the world
>>
>>54335408
http://pastebin.com/B2AA265z
>>
File: yuck.jpg (46 KB, 800x613) Image search: [Google]
yuck.jpg
46 KB, 800x613
>>54335426
>Hacker News
>>
>>54335306
we've talked about that actually, two of them are in music-related majors and one is in some art/animation program. we could do gamedev.
>>54335311
normie compared to what I used to do, which is program obsessively and shitpost and nothing else
>>
>>54334899
>i cant see how its choosing one of the possible classes over the other.
It's done based on the actual class op belongs to. As for
(Operation) input
, it's a cast. Google it. That must mean input isn't already an Operation.

Off 4chan now sry
>>
File: projecting.jpg (692 KB, 1920x3518) Image search: [Google]
projecting.jpg
692 KB, 1920x3518
anyone have an explanation of how perspective projection works that doesn't suck fucking ass?

and why do people act as if rectilinear projection is the only way to do perspective projection? it clearly has its disadvantages
>>
>>54335452
>my only argument in defense is ad hominem
>>
File: greg1-1038x576.jpg (91 KB, 1038x576) Image search: [Google]
greg1-1038x576.jpg
91 KB, 1038x576
>>54335452
>anonymous shitposting
>being a hipster who only likes C because it's 'vintage' and le epic unix philosophy meme
>>
>>54335426
>It is unethical to continue writing code in non-memory-safe C or C-based lanugages, for any purpose. Period.
>unethical
how delusional
>>
>>54335464
im retarded, thanks
guess its time to make more coffee
>>
>>54335426
Fucking hell. I hate the words "considered harmful".
>>
>>54335426
all of that could've been prevented if people didn't outsource to India
>>
>>54335539
https://wiki.theory.org/YourLanguageSucks#C_sucks_because
>>
File: set7-header-original.jpg (127 KB, 1280x400) Image search: [Google]
set7-header-original.jpg
127 KB, 1280x400
>>54335464

This guy's right at the basic level, but I assume you already know what a cast is if you're flicking through this codebase

>>54335434

This is some weird meta-level shit right here. So Process must inheret from IEnumerable because it's used in a foreach loop under SetEnabled().

More or less I'm going to assume the other two classes that inheret from Operation are for the other methods here: Init() and ToString(). What's more or less happening here is inheritence to give you a "clearer" public interface to the ProcessFlow handler that manages your processes.

Let me break it down into something procedural so that it might be a little clearer.

Somebody creates an object at runtime called "Honda" and gives it to you as a "Thing". Your program tells you, "this is a car" which is the casting stage and looks like
 Car myCar = (Car) funnyObject 


Now all you know about cars is that they can "Go" "Stop" and "DoSickDrifts" and you want to do the third one on your generic car object

 myCar.DoSickDrifts() 


Now, at runtime, you have the luxury of knowing that your car is ACTUALLY a Honda, so you look up the Honda class for how to actually DO a sick drift

 class Honda : Car
public override DoSickDrifts()
{
PutClutchIn();
PullUpEBrake();
PedalToMetal();
}


and that's basically it.

In this case you're given a generic "input" which is some sort of "operation". You "do" the operation, and at runtime you find out the operation is one of three possible operations, and you execute the operation on your ProcessFlow
>>
File: the new furfags.png (78 KB, 1306x354) Image search: [Google]
the new furfags.png
78 KB, 1306x354
>>54335541
>implying the heartbleed code was written by an outsourced Indian
How dumb are the /pol/tards on this board?
>>
File: 1423846779490.png (56 KB, 200x150) Image search: [Google]
1423846779490.png
56 KB, 200x150
>>54335495
You know OOP is a meme, right?
>>
>>54335587

hello rajeed
>>
>>54335561
>Manual memory management can get tiring.
not being retarded doesn't get tiring though
>String handling is manual memory management. See above.
there are good string libraries that are ANSI/C89 compatible
>The support for concurrent programming is anemic.
Multithread is hard, yeah, but to say C doesn't support it is retarded.
>Terribly named standard functions: isalnum, fprintf, fscanf etc.
True, but you grow accustom to them.
>The preprocessor.
The preprocessor is good.
>Not feeling your smartest today? Have a segfault.
retarded
>Lack of good information when segfault occurs... the "standard" GNU toolchain doesn't tell you the causes of segfaults in the standard runtime.
blatantly false. It tells you EXACTLY where the segfault is.
>If that code is legacy, you're in for two days of not looking like a hero.
what
>There is no boolean type
#define TRUE 1
#define FALSE 0
>>
File: why havent you left yet.png (254 KB, 546x700) Image search: [Google]
why havent you left yet.png
254 KB, 546x700
>>54335623
I'm white actually, it's just funny because the heartbleed vuln was actually introduced by a German and it was an Indian who discovered it, top kek.
>>
>>54335641
fuck off patel
>>
File: maga.png (292 KB, 583x343) Image search: [Google]
maga.png
292 KB, 583x343
make_great_again(&america);
>>
File: stormfags.png (135 KB, 1155x852) Image search: [Google]
stormfags.png
135 KB, 1155x852
>>54335649
Stay mad stormcuck.

PROTIP: If you can't compete with curryniggers, maybe they deserve it more than you? Insecurity makes you look like a massive cuck.
>>
>>54334406

Psh, if you want an embeddable scheme, try TinyScheme.

>>54335426

>Not for libraries, not for drivers, not for operating systems. It has to go.
It is completely impossible to write an operating system without complete control over memory, which immediately opens up the same vulnerabilities one derides C for. Operating Systems have been written in high level languages like Java before, yes, but they rely heavily on a backend written in assembly to get any real dirty work done. There is an inherent need for programming languages without memory safety in certain areas, and consequently, C was created for just that purpose. Was C created for making libraries? No, it was created for making Unix. That it became popular for its level of control is why it is now used for making libraries. As it turns out, because the majority of operating systems are written in C, and so are their documented system calls, libraries that have to interact with the operating system are often best written in C, and then given hooks into other languages through a foreign function interface.

Whoever wrote that post is a complete dumbass who doesn't know why low level languages exist in the first place.

>>54335625

>preprocessor macros
>not just including the stdbool.h header
>>
>>54335692
You can write an OS in rust
>>
>decide how my hands at java / poodroid
>install android studio, the jdk, get the SDK and all the dependencies, an armv7 image to play around with shit
>shitloads of errors, missing libraries, gradle builds taken half an hour, package updates are original package size + changes as opposed to just changes taking gb's
poordroid, not even once
>>
>>54335692
You can write the high level parts of the OS in some scripting language, and the core parts in assembly. There's literally no reason to use C - It's worse at low-level code than assembly, and worse at high level code than literally every single language.
>>
>>54333580
>use haskell for shell scripting
>don't benefit from neither the ecosystem nor the static typing
                                                                        
#!/usr/bin/env stack
-- stack --verbosity 0 --install-ghc runghc --package turtle

{-# LANGUAGE OverloadedStrings #-}

import Turtle
import Data.Bits
import Data.IP
import Data.Text (pack)

lastAddr :: AddrRange IPv4 -> IPv4
lastAddr r = toEnum $ fromEnum (addr r) .|. shift 1 (32 - mlen r) :: IPv4

tryPing :: IPv4 -> IO (IPv4, Bool)
tryPing ip = do
(x, _) <- procStrict "ping" ["-c 1", pack . show $ ip] empty
case x of
ExitSuccess -> return (ip, True)
ExitFailure _ -> return (ip, False)

parser :: Parser (AddrRange IPv4)
parser = argRead "IPRANGE" "The IP range to ping"

main :: IO ()
main = do
subnet <- options "Simple IP subnet mass ping tool" parser
let ips = enumFromTo (addr subnet) (lastAddr subnet)
results <- mapM tryPing ips
let worked = filter snd results
putStrLn "Successfully pinged:"
mapM_ (print . fst) worked

Usage:
> $ ./pingu.hs faggots                                                                             
Simple IP subnet mass ping tool

Usage: pingu.hs IPRANGE

Available options:
-h,--help Show this help text
IPRANGE The IP range to ping

> $ ./pingu.hs faggots
Simple IP subnet mass ping tool

Usage: pingu.hs IPRANGE

Available options:
-h,--help Show this help text
IPRANGE The IP range to ping


Also: stack is fucking awesome
>>
>>54335541
It could have also been prevented if nobody used fucking debian

The latest stable release of fedora was immune when heartbleed became public knowledge

Clearly, debian is going to be our downfall. Gott strafe debianer.
>>
>>54335746
oops borked the last example
> $ ./pingu.hs 127.0.0.1/30                                                                        
Do you want to ping broadcast? Then -b
Successfully pinged:
127.0.0.1
127.0.0.2
127.0.0.3
127.0.0.4

It doesn't only support a "faggots" argument :^)
>>
>>54335746
i have never seen haskell code that looks good. there is no hope for this language.
>>
>>54334812
Your definitions are too long. Reread thinking forth and try again
>>
>>54335746
also that "case of" is absolutely retarded
tryPing ip = do 
putStrLn $ "Pinging " <> show ip <> "..."
(x, _) <- procStrict "ping" ["-c 1", pack . show $ ip] empty
return (ip, x == ExitSuccess)


>>54335807
beauty is in the eye of the beholder (^:
>>
>>54335701
Rust gives you as complete of control over memory as C does. I've played around with the language, and even if you're just writing Rust like C, it's pleasant to work with. Unfortunately, Rust came out after every major operating system, and it's a bit too late to port everything over.

>>54335721
Of course you can write the core parts in assembly. But nobody does this because it's a pain in the ass to write in compared to C, and it isn't as portable. Nobody uses scripting languages for the high level parts of the operating system because the idea is to spend as little time in the kernel as possible. It's fine to write user level code in higher level languages, but when you're at the lowest level possible, performance fucking matters.

Also

>worse at low-level code than assembly
In many cases, the assembly generated by a C compiler is better than what most equivalent humans could write
>>
About two months away until I'm done with an iOS/Android app.

I'm using Nativescript and Angular 2. No objective-c/swift/xam/any of that bullhonk. It's lit senpai
>>
>>54336008

>Writing a mobile application in JavaScript
So it can run like ass on both Android and iOS at the same time?
>>
>>54336029
Look into Nativescript. Runs like butter on iOS and android. Soon windows phone, too. It compiles to native, senpai.

Nothing like phonegap.
>>
>>54334119
[email protected]
>>
>>54334509
All of them are correct
>>
>>54335746
also there is a bug in lastAddr
final version, I'm done sorry for spamming
#!/usr/bin/env stack
-- stack --verbosity 0 --install-ghc runghc --package turtle

{-# LANGUAGE OverloadedStrings #-}

import Turtle
import Data.Bits
import Data.IP
import Data.Text (pack)

firstAddr :: AddrRange IPv4 -> IPv4
firstAddr = addr

lastAddr :: AddrRange IPv4 -> IPv4
lastAddr r = toEnum $ fromEnum (addr r) .|. (shift 1 (32 - mlen r) - 1) :: IPv4

tryPing :: IPv4 -> IO (IPv4, Bool)
tryPing ip = do
putStrLn $ "Pinging " <> show ip <> "..."
(x, _) <- procStrict "ping" ["-c 1", pack . show $ ip] empty
return (ip, x == ExitSuccess)

parser :: Parser (AddrRange IPv4)
parser = argRead "IPRANGE" "The IP range to ping"

main :: IO ()
main = do
subnet <- options "Simple IP subnet mass ping tool" parser
let ips = enumFromTo (firstAddr subnet) (lastAddr subnet)
results <- mapM tryPing ips
let worked = filter snd results
putStrLn "Successfully pinged:"
mapM_ (print . fst) worked
>>
so I want to start doing some web development, if only on the side
i'm kind of neeting it up right now, so I was thinking about what hot new tech I should learn
considering i'm coming from a background in c, c++, java and lua, should i go for golang or elixir?
some thoughts include that elixir is pretty different and that erlang is known to scale well, while go is very small and unix-like and i'd probably adopt idiomatic golang faster
>>
>>54335581
other anon was right, they were already created elsewhere and i was just being retarded
>>
>>54334848
>tfw she knows more about programming than me
>tfw the video was nowhere near as bad as I thought
>>
>>54336075
do xor gates actually exist, though? or are we saying (A∨B)∧¬(A∧B) when we say (A⊻B)
>>
File: Screenshot_2016-05-02-08-15-13.png (110 KB, 720x1280) Image search: [Google]
Screenshot_2016-05-02-08-15-13.png
110 KB, 720x1280
I want to program on android. But I can't find a keyboard which keeps a list of identifiers/language keywords.
Not even programming specific keyboards do that.

Anyone tried this? Any recommendations?
Do I have to write my own keyboard first? Or should I look at cppdroid first?
>>
>>54336124
why would you want to program on a phone?
sincerely curious
>>
>>54336124
>But I can't find a keyboard which keeps a list of identifiers/language keywords.
>Not even programming specific keyboards do that
Because most languages have a lot of keywords, and most of them are really short. In the time it takes to fluff around finding the keyword, you could have just typed it.

But the real question is: why the hell are you trying to program on a mobile device?
>>
>>54336164
>>54336151
>why the hell are you trying to program on a mobile device?
Why wouldn't you want to program everywhere?
I sit on the toilet, on the bus, waiting wherever a lot. Could spend that time doing something.
>>
>>54334953
Look up how variable escaping works with single and double quotes

~ $ var1="variable one"
~ $ var2="variable two"
~ $ echo "variable one is set" | sed "s/$var1/$var2/"
variable two is set
>>
>>54336209
because how effective would you really be that the opportunity cost is worth it

i dunno, maybe i think i sit in front of a screen enough already so i savor the time to do anything else
>>
>>54336209
>Programming in short intervals
>Trying to do something which requires intense concentration in a public setting
>Trying to program in some shitty environment with a shitty input system
Yeah, no.
>>
>>54336209
you must be new as hell to programming if you think most of the time spent is writing code.
>heh while taking a shit i was able to finish the 2nd half of that for loop!
>>
>>54336105
did she know it?
she was surely reading cue cards.
she did have an aversion to saying the word 'shit'
>>
>>54336209

>on the toilet
>on the bus
What is a laptop?
>>
>>54336378
cause or effect?
drop in toilet because the code is shit? <or> code is now shit because it was dropped in the toilet?
>>
>>54334119
are you still there?

[email protected]
>>
A proof just isn't good unless it makes you feel like a cheap ass afterwards.

>>54336410

Or maybe the code is shit because it was written on the toilet? Personally, I do 90% of my programming on my bed.
>>
>>54334119
[email protected]
>>
Are there any reasons to use Rust over D?
>>
>>54336523

Not wanting a garbage collector.
>>
How do I Haskell in Python?

for r, s, files in os.walk('.'):
files = filter(lambda f,x: x == '.txt', map(os.path.splitext, files))

for file in files:
print(file)
>>
>>54336581
That's not a lot of reasons.
>>
>>54334202
I suggest you learn more about C++ before diving into librairies written for it.
Take a look at Herb Stutter's or Bjarne Stroustrup's books for example.
>>
>>54334848
That's painfully obviously just scripted content that someone hired her to say or some form of cooperation between her and the writer and editor. Basically weather forecast for programming.
>>
>>54336667
Why, because women can't code? Fuck off to >>>/pol/ with that sexist crap... THIS is why we don't have more women in the industry.
>>
>>54335407
I'd say C++ today makes C obsolete given it can do exactly the same job in a much safer way.
Still I share your pain sometimes, CTOs are way too much into Java because it's usually cheaper labour.
>>
>>54336699
>>54334860
>>54334898
I can't tell if this is viral marketing or a transcendent level of shitposting.
>>
>>54336699
top kek
>>
>>54336592

You asked if there were any, not if there were many. Word choice is important.
>>
>>54336280
No maybe it just gets clearer to consider code while looking at it. It's no real art to synchronizing the files between mobile and laptop so it can always be up to date. I've found that I have ideas I need to note them down rather than write something more descriptive.
>>54336278
>intense concentration
Not always sadly. Also see above.
>>54336269
>I appreciate my non-programming time
I guess. I don't generally. I get restless.
>>
>>54336738
turns out I didn't like where it was going desu
>>
>>54336209
>Why wouldn't you want to program everywhere?
Because I'm not a fucking programming robot and actually do other things such as read fiction and news, socialize, learn a human language or simply think about something.
>>
>>54336760
I guess I just expected some Rust fanatic to give me a whole list of reasons :P
>>
>>54336699
lol
Maybe the writer and producer is a woman. You're the sexist here.
>>
>>54336782
I meant why wouldn't you want the option rather than why you wouldn't. Sorry.
>>
>>54334848
I have to admit that it is really stupid and cringeworthy, even though I appreciate the service it's done in triggering SJWs.
>>
>>54336794
we don't really have rust fanatics here

only D fanatics
>>
>>54336782
kek
>reading fiction
>time better spent than programming
read more programming books!
or at least some history
anything non-fiction and informative
>>
>>54336836
rust is the latest meme get with the times grandpa
>>
I need something to kickstart my Android development.
Suggest a Java book for intermediate programmers (previous experience include C/C++ and Python).
>>
File: lou bega tips le fedora.gif (3 MB, 250x257) Image search: [Google]
lou bega tips le fedora.gif
3 MB, 250x257
>>54336846
>fiction is a waste of time
>>
Can someone please explain why the fuck CSS validator gives me 10 of this exact same error:

Parse Error Lexical error at line 2, column 22. Encountered: " " (32), after : "<!DOCTYPE html PUBLIC"
???

I CANNOT declare DOCTYPE before my session, so what the metric fuck do I do to make it validate?

Can I, or will I just submit it as is?

>school project
>>
>>54336855
get off me lawn ya darn whippersnappers
>>
>>54336856
Java for Dummies 9-in-1

like, why the hell not?
>>
>>54336878
cuz i.. i'm not a dummy..
>>
>>54336782
>read fiction
goddamnit it's this sperg again
>>
>>54336856
>intermediate
Not descriptive enough to give an accurate recommendation.

Really I find that most OOP languages are pretty much the same. I guess Java requires you to have a container class for your main. That's it. As far as writing code anyway. The Java VM is another beast.
>>
>>54336865
the vast majority of fiction is utter bollocks and a complete waste of time
>>
>>54336886
Well, neither is the book. After a few chapters, it covers more advanced stuff.

How bout something mostly dry and rip-you-hair-out obnoxious, instead?
>Data Structures and Algorithms in Java by Peter Drake
or something that forces you to program games to learn it?
>[also] Data Structures and Algorithms in Java [but] by Robert LaFore
>>
>>54336846
I'm sure if I wanted to solely improve my programming and fact knowledge the time I spend reading fiction would be wasted but as you can imagine it's not my singular goal.

>>54336799
You just need access to your repositories on a browser and a notebook to write down your brilliant poop ideas. Much more comfortable than using the screen keyboard too.
>>
>>54336907
>the vast majority of fiction is utter bollocks and a complete waste of time

Like your life?
>>
>>54336856
just plow through https://docs.oracle.com/javase/tutorial/
>>
>>54336937
now
that's what i call
butthurt
>>
>>54336870
anyone?

if not, I'm just gonna zip it and submit it as is.
>>
>>54336932
I guess I'll see what the dummies book has to offer.
But I'd rather just print the whole tutorialspoint.com Java pages and read that.

>>54336945
This guy gets it.
Thanks, I'll check it out.
>>
>>54336962
ask >>>/g/wdg/

they know css shit
godspeed anon
>>
>>54336870
I mean... is there a space before the closing bracket?
>>
>>54336870
how do you expect people in a PROGRAMMING thread to know or give a fuck about this obscure webshit

>>>/g/wdg
>>
>>54334403
It probably returns an internal IP adress. The server may work, but it doesnt listen on that IP. You need to obtain your external IP.
>>
My own Makefile-based build system.

This shit is the stuff of wizards. I can't even believe the shit it's doing
>>
>>54336907
The vast majority of everything sucks. Answering to me right now is also a waste of time.

Go and engage /lit/ in this discussion, I'm sure they are thirsty for their next shot of STEM hate and you'll enjoy it just as much to bash them.
>>
>>54335617
what anime
>>
>>54337011
boku no pico
>>
>>54336978
huh? There's no brackets. Do you mean ">"? If so, then no.

>>54336981
Because markup is very related to programming?
And markup is also included in programming, such as PHP, Perl, JS, etc.?

>>54336977
Fine, I'll check with them quick. If the thread isn't fucking dead...
>>
>>54336985
your mum sucks but she wasn't a waste of time
>>
>>54334119
[email protected]
>>
>>54337048
KILL YOURSELF
I
L
L

Y
O
U
R
S
E
L
F
>>
I have to make a python game where I have to find a word from a list of words in a file, what's the fastest way to check if the word is in the file?
search in f.readline() or making a dictionnary/list from the words file I have?
>>
>>54337397
depends
if you only want to check one word, than you can just make iterate over the file and compare each line to your word
if you have to find multiple files, you read the entire dictionary into a hashtable (or python equivalent)
>>
>>54337397
either will yield results in nanoseconds
if you are asking to write the program
prolly quicker to write a readline script
>>
>>54337414
that's the point, I have one file, and I'd like to check the fastest way possible if the word is in the file
>>
>>54337427
try them both
do your own homework
>>
>>54337427
Should probably not concern yourself with what's fastest unless your assignment demands it.
>>
>>54337462
I have to deal with the time complexity, that's why I'm asking for the fastest way to search
>>
>>54337420
>python
>results in nanoseconds
pick one
>>
>>54337485
get a pc that doesn't run on vacuum tubes and you'll see it process in nano seconds
>>
>>54333491
>D
GC has overhead
Interfaces have overhead
Classes are managed and have overhead

>Nim
Compiles to C++
>>
>>54337529
>interfaces and classes
if you're concerned about overhead, you should be staying right the fuck away from object orientation anyway
>>
how do you handle desync issues in distributed programming?
like, if the client contacts the server, asking it to insert a row into the database, and then the server crashes
the client has no idea whether the server completed the task before crashing but didn't have time to send an acknowledgement back to the client
>>
>>54337541
If the client gets no response then it can assume it failed.
>>
>>54337533
You can have 0 overhead object orientation just by avoiding inheritance
>>
>>54337556
>then it can assume it failed
and if it didn't?
>>
>>54337566
or inheritance with virtual functions rather
>>
>>54337528
lol python is so slow it'd probably take like a second to process a decent sized file
>>
>>54337567
the server should take the request again without issue
>>
>>54337567
then nothing should go wrong anyways. The client should not break because it thinks something that was committed to the database was not committed.

Imagine posting on 4chan, and because of a network error you never see confirmation that your post was made even though it was. No problem, you can see there was a network error, and you just refresh the thread to see if the post was committed or not.
>>
>>54337566
use structs with member functions
>>
>>54334099
Just take a drag&drop pseudocode and remove the constraint the the item must be clicked.

IIRC sigma.js has a straightforward implementation of drag&drop, i was kinda amazed at the simplicity of it, considering it was arcane to me 5 minutes earlier.
>>
I've seen the term 'code monkey' thrown around on /g/, especially /dpt/, but I don't know it's meaning. For example 'CS graduates are glorified code monkeys' or 'enjoy being a code monkey for a living ' etc.
>>
>>54335976
There's a project reimplementing a kernel in rust. Emphasis on NOT being 100% POSIX compatible. They're being quite dicks about, tho.
Well what matters is the finished product, I guess.
>>
File: 2nd.png (164 KB, 1080x1845) Image search: [Google]
2nd.png
164 KB, 1080x1845
>never written Java before in my life
>spend the last two days figuring out how to use Android studio and writing a wifi app
>get it finished, get the layout all nicely arranged and versatile, meets all the guidelines
>go to sign up to put it in the market for free for people
>$25

Y u do dis google? :(
>>
>>54337714
costs money to host your app literally and legally
>>
>>54337722
Well, on the bright side, now I can write Java.

Hell of a leap from VB6 where all the data type assignment/conversion is just about invisible.
>>
>>54337714
I hate you so much for this color scheme
>>
>>54337714
see this:
>>54337722
also, they want to cut out any asshats uploading shit files for the hell of it like some /b/tard
plus, to verify you identity in case some shit, copyright infringement, malicious code, abuse of user's cameras, etc...

basically, for the benefit of the end user.

go ahead and add some ads to it to recoup your costs maybe
>>
>>54337666
Nice trips.

Here in Italy, programmers are just glorified labor. We don't even earn more, despite the investment in learning. Despite being critial to "market an idea", the management/marketing/design/whatever will get more credit for their work.
No actual career opprtunity, except if you specifically step outside of the domain. You start as a coder and you die as a glorified coder.

Also, once you grasp the basics it's easy to get by with copypastan shit from stackoverflow. Nonprogrammers can't tell the difference.

Sigh.
>>
File: 5th.png (129 KB, 1080x1845) Image search: [Google]
5th.png
129 KB, 1080x1845
>>54337748
Lucky you won't have to use it then seeing as I'm not paying jewgle $25 to put a free app in their shop.

I did try to change the schemes, it won't let me change it away from that pink underline.
>>
>>54337765
Just put it in f-droid
>>
>>54337765
you can host the apk on github, google drive, dropbox, one drive, etc...
>>
>>54337777
Can't you just install random apks without having to root your phone on Android?
>>
>>54337765
What does it do, specifically?
>>
>>54337800
yes
you have to get in phone settings and allow 3rd party apps. easy. but normies don't know how
>>
>>54337760
>my costs

This is another thing I don't get. What fucking costs are there meant to be?

The studio is free. I already have a computer, although it struggles to run the Android Studio. I never once programmed anything even in an OOP language letalone Java itself, it took me all of two days to pick it up and start writing competently.

What "costs"?
>>
>>54337807
Gives me 3 preset options for my mobile hotspot, each with their unique options. Turn it off if power's below X%, reactivate it if it was turned off once it's plugged into power again, and auto-turn it on when I select that set.

Also stores 3 different wifi names and passwords. Now I can have one for when I'm at home, a different network/password for using at work/customers places, and a 3rd one in case I need it for something.
>>
>>54337815
the $25 you were just bitching about, dumbfuck
ok, not dumb if u coded from scratch in 2 days. but damn, learn to read the thread and follow replies.
>>
>>54337826
Oh. right.

It's late.
>>
git-based 4chan archiver in node.js using json API

converts each post to a timestamped commit, stores all thread data in file-based data structures
>>
File: average java programmer.png (371 KB, 800x600) Image search: [Google]
average java programmer.png
371 KB, 800x600
>>54337744
>>
>>54337848
nice. how far back does the archive go?
does it monitor every thread on every board?
>>
>>54337848
That seems like a really inappropriate use of git.
>>
>>54337744
>2016
>VB6

People still use that crap? I had hoped it died already.
>>
>>54337848
Why not store it in Pi?
>>
>>54337848
>converts each post to a timestamped commit
>tfw i finally know what people are talking about when they say commit now

public boolean iAmCharging() {

IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
Intent batteryStatus = getApplicationContext().registerReceiver(null, ifilter);

int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING ||
status == BatteryManager.BATTERY_STATUS_FULL;

return (boolean) isCharging;

//return true;

}

public void doConnection() {

TextView wConStat = (TextView) findViewById(R.id.txtWifiState);

wConStat.setTextColor(Color.rgb(170, 170, 0));
wConStat.setText("Enabling...");

if (!setHotspotName(netName[activeSet], getApplicationContext())) {

Toast toast = Toast.makeText(getApplicationContext(), "Could not enable. Please check your settings.", Toast.LENGTH_SHORT);
toast.show();
wConStat.setTextColor(Color.rgb(170, 0, 0));
wConStat.setText("Failed");
return;

}

if (!setHotspotPassword(netPass[activeSet], getApplicationContext())) {

Toast toast = Toast.makeText(getApplicationContext(), "Could not enable. Please check your settings.", Toast.LENGTH_SHORT);
toast.show();
wConStat.setTextColor(Color.rgb(170, 0, 0));
wConStat.setText("Failed");
return;

}

if (!setHotspotState(true, getApplicationContext())) {
Toast toast = Toast.makeText(getApplicationContext(), "Could not enable. Please check your settings.", Toast.LENGTH_SHORT);
toast.show();
wConStat.setTextColor(Color.rgb(170, 0, 0));
wConStat.setText("Failed");
return;
}


}


>>54337859
>people really spend years studying to learn it
>>
>>54337867
It monitors whatever thread I tell it to

I can also set up NSA-like selectors which will filter the huge amounts of information and immediately start thread surveillance if it catches anything :3

>>54337870
Why

>>54337878
In a what now
>>
>>54337871
VB6 is cancer
But there is literally nothing wrong with VB.Net
>>
>>54337887
Just search through Pi until you find the digits equivalent to the serialised post and save the index
>>
File: vb6.png (250 KB, 1920x1080) Image search: [Google]
vb6.png
250 KB, 1920x1080
>>54337871
Hell no. VB6 lives on at the very least in VBA. Makes it really easy to interface with Outlook/Excel too. Some of the programs I've written in it will be used by companies for another 10 years, easily.
>>
File: maverick.jpg (126 KB, 1211x1210) Image search: [Google]
maverick.jpg
126 KB, 1211x1210
>>54337911
That's amazing m8
>>
>>54337923
Yeah, and what you can then do is save the index itself in Pi. Then all you need is an extra number to count the number of applications
>>
>>54337911
if it's probable that the size of the index is lower than the size of what you want to store, couldn't you repeat this and store the index in the same way?

>yfw information is infinitely compressible
>>
>>54337945
>>54337934
oh for fuck's sake I should have read further
>>
>>54334099
I haven't slept in a while, so maybe this doesn't make any sense whatsoever.

But it works.

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class DragAndDrop extends JPanel{

public static void main(String[] args) {
DragAndDrop panel = new DragAndDrop();
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(panel);
frame.pack();
frame.setVisible(true);
}

int x = 225;
int y = 225;
int width = 50;

Point mousePosition = new Point(x,y);
Point clickedPosition = new Point(x,y);

public DragAndDrop() {
setPreferredSize(new Dimension(500,500));
setBackground(Color.WHITE);
DragAdapter d = new DragAdapter();
addMouseListener(d);
addMouseMotionListener(d);
}

@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.BLACK);
g.fillRect(x, y, width, width);
}

public void setMousePosition(Point p) {
mousePosition.x = p.x;
mousePosition.y = p.y;
}

public void updateClickedPosition(Point p) {
clickedPosition.x = p.x - clickedPosition.x;
clickedPosition.y = p.y - clickedPosition.y;
}

public void updateElementCoordinates() {
x = mousePosition.x - clickedPosition.x;
y = mousePosition.y - clickedPosition.y;
repaint();
}

public class DragAdapter extends MouseAdapter {
@Override
public void mousePressed(MouseEvent e) {
updateClickedPosition(e.getPoint());

}

@Override
public void mouseReleased(MouseEvent e) {
updateClickedPosition(e.getPoint());
}

@Override
public void mouseDragged(MouseEvent e) {
setMousePosition(e.getPoint());
updateElementCoordinates();
}
}
}


When dragging, it updates the element's coordinates, so that it moves the same amount that the mouse has moved since the last event.
>>
>>54337977
mate just override the - operator for po-
hahaha
>>
>>54337815
if you're gonna publish shit you threw together in literally a couple of days then the least you could do is pay a one time fee of $25

to publish on iOS is like $100/year
>>
>>54337997
>the least you could do is pay a one time fee of $25
>implying i'm paying for the privilege of spamming the market with useless broken shit

I tested it out the ass, it works down to API 10, on big screens, tiny screens, landscape, it's idiot proof, checks what needs to be checked, and does what it needs to do.
>>
>>54337977
If it works, that's great.
I'd suggest to rename clickedPosition with mouseDownPosition.
Why do you need to updateClickedPosition on mouseReleased?
>>
>>54337887
>Why
The data you're storing doesn't fit a version control system at all and doesn't benefit from any of its features.
>>
>>54338020
>being this entitled
just put it on f-droid dude
>>
File: 1457266792302.png (222 KB, 629x500) Image search: [Google]
1457266792302.png
222 KB, 629x500
>>54338020
>it's idiot proof
>>
To all the gui masters out there. Im trying to learn them and wanted to know if I could open a file the same way I would c++ in a framework such as QT designer or would I have to learn how to do it in QT.
>>
>>54338029
Uh

Git will literally dedup all the image files, every commit maps directly to a post and first commit maps to thread OP, can store all thread metadata in git such as when my archiver detected that a post has been deleted (it becomes a commit)

It's much better than simply saving all this crap in a bunch of regular file system constructs. Git is best 99/10
>>
>>54338079
What if you want to store an image of an eggplant?
Thread replies: 255
Thread images: 35

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.