lainchan / λ

The Beginner's General

λx.x · 2017-12-24 23:41
This is the Beginner's General for beginners' questions. If you have a simple question and a suitable thread doesn't already exist, just post it here and someone will probably try to answer it for you. Remember to do some research before asking your question. No one wants to answer a question that a simple search can already resolve.
Cutter · 2017-12-25 02:29
>>5824 I am always fascinated by malwares and malware analysis, someone direct me toward good resources and books to read as a begineer I am currently learning advance C and Python
Ender · 2017-12-25 05:17
>>5825 If you want to actually do malware analysis, you will need to learn assembly and how to use a disassembler before too long since it is a necessity these days. I'd start with 6502 assembly (https://skilldrick.github.io/easy6502/index.html) and work your way up if you want a gentle introduction. C and Python alone wont cut it. You will also need to be proficient in web technologies (html, css, javascript, etc). Having intimate knowledge of the Windows API is also quite useful, since that is what most malware is targeting. Anyways, here are a few links to give you an idea what is involved, as they do this sort of thing: https://securelist.com/ - Kaspersky https://blog.malwarebytes.com/ - Malwarebytes, obviously https://bartblaze.blogspot.com/ - not updated very often, but interesting I am sure I am missing a lot, as I am no malware expert myself but have the same interest.
John Titor · 2017-12-25 06:24
>>5828 I have bought "The Art of Assembly Language" and "Assembly language Step-by-Step" and planning to start reading from next month. Which book should I start reading as I am totally new to assembly? I know little bit about html and css but haven't touch js.If I have to choose between js and php at first which language should I learn first and why? Thx for the links anon, I will definitely check it out.
let · 2017-12-25 08:50
>>5830 >I have bought "The Art of Assembly Language" and "Assembly language Step-by-Step" and planning to start reading from next month. >Which book should I start reading as I am totally new to assembly? If I'm recalling the correct title, I'd start with the former, but you'll probably be fine starting with either; I doubt you'll be programming intensively with an assembler after just one book. You may want to look into this thread, as well: >>43
Hong, Guil Dong · 2017-12-26 11:55
Ok so, I have been working using SQL ORACLE and it showed me the "missing expression" error and i dont know where i fuarrrked up. I'll post my code select c.doc, c.numdoc, c.nombre ( select min(desde) from alquileres a where c.cliente = a.cliente group by c.doc,c.numdoc.c.nombre) as "primera" from clientes c group by c.doc,c.numdoc.c.nombre; select min (a.desde), count (a.desde) from alquileres a right join clientes c on a.cliente = c.cliente;
Torvalds · 2017-12-27 22:51
I'm interested in programming language theory and compilers design. Where should i start? I have 0 background in theoretical cs, but i have background in programming (have made an application with qt)
Dozer · 2017-12-27 23:28
>>5885 You probably want to learn about formal semantics and write some interpreters first, rather than jumping straight into compilers. SICP is a good starting point, especially if you're a beginner with computer science in general. I can also recommend Write Yourself a Scheme in 48 Hours: https://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours.
⍕ · 2017-12-28 00:34
>>5888 I thought SICP was just an intro to Scheme and some programming techniques, but now looking at the contents it looks like i was completely wrong. Thanks.
Special Agent Bob · 2017-12-28 09:53
>>5885 +1 for SICP as a book to start with. Language Implementation Patterns by Parr is a good next step. The examples are in Java but are simple enough to rewrite in your language of choice. The use of a specific tool (ANTLR) could be problematic so look into how this will fit into your language and tooling choices. The good thing about this book is that it fills that gap between the likes of SICP and university compiler texts (like the next recommendation) while sharing practical wisdom for implementation along the way. Programming Language Pragmatics by Scott is a proper course written with self study in mind. If you can get through this book then you'll be at a level where you can explore more advanced topics on your own. If Racket happens to be your language of choice then I can definitely recommend Beautiful Racket before SICP. While knowledge of Racket isn't assumed some experience with the language and ecosystem will help you get the most out of this imo.
John Doe · 2017-12-29 01:16
I just discovered the variable $IFS, which has made my life much easier when iterating through files in bash scripts, as I hate replacing spaces with underscores. But I was wondering, what is the reason that the space is included in the default IFS ? Things like for i in {1..$n} or for i in $(ls) seem to work fine without it.
vector · 2017-12-29 11:29
>>5909 >for i in $(ls) That works without space in IFS because command substitutions are executed in a subshell [1] with standard output being a memory buffer, and because [2]: """List one file per line. This is the default for ls when standard output is not a terminal.""" >what is the reason that the space is included in the default IFS ? Most people expect a 'for' to loop through space-separated tokens. For example: for num in $(factor 1000000000) will be less than useful without space in IFS. [1] https://www.gnu.org/software/bash/manual/html_node/Command-Substitution.html#Command-Substitution-1 [2] https://www.gnu.org/software/coreutils/manual/html_node/General-output-formatting.html#index-single_002dcolumn-output-of-files
Unspecified · 2017-12-29 11:39
>>5845 There's no comma between c.nombre and the embedded select. Also, the grouping in the embedded select is a little suspect.
Leto Atreides I · 2018-01-03 06:58
This exercise is simple but I'm having trouble compiling it The basic idea is that the user should give the program the letter 'a' and then the program prints the alphabet. If my program works or not is an issue I'll work on later /*array of 26, all the alphabets letters and prints them*/ /*a = 97 z = 122*/ #include <stdio.h> int main(void) { char alph[25]; printf ("type 'a' and get the alphabet "); scanf (" c" &alph[0]); //the compiler doesn't want to accept this line do { alph++;//the compiler says this is missing an l-value } while(alph < 122); printf ("c", alph); return 0; }
Lord Nikon · 2018-01-03 07:39
>>5974 Look at the scanf and printf function calls. Something is missing.
藤原純一 · 2018-01-03 08:37
>>5976 I feel like such an idiot now Thanks
John Rain · 2018-01-04 03:19
>>5974 >>5976 I fixed the missing % on the scanf and printf but the compiler gives me the same errors ejr.c: in function ‘main’: ejr.c:10:18: error: invalid operands for the binary & (have ‘char *’ and int’) scanf (" %c" &alph[0]); ^ ejr.c:14:13: error: l-value required as increment operand alph++; ^ ejr.c:16:16: warning: comparison between pointer and integer while(alph < 122); ^
Wirth · 2018-01-04 03:58
>>5986 >scanf (" %c" &alph[0]); You need a comma between arguments. >alph++; ++ won't work because alph cannot be assigned to. It cannot be assigned to because it's the name of a sequence of boxes holding chars, rather than the name of a box holding the address of a sequence of boxes holding chars. Try going through your array with an index. >while(alph < 122); Try comparing an array element rather than the array itself with the sentinel value. Also, your array is uninitialized.
Nell · 2018-01-04 18:14
I want to read a fair amount of programming/tech related books that look like The Little Schemer, The Little Prover or The Little Book Of Semaphores. Would you mind sharing books (maybe just the titles) that match the spirit ? Thanks to all.
queue · 2018-01-05 04:07
>>5987 My program compiles now but I think i should redesign it now Thank you
Von Neumann · 2018-01-05 17:47
very generic question What is a good software project a single person could finish in 2-3 months? any advice is welcome ty
progn · 2018-01-05 23:11
>>6004 A Lisp, a full-featured CMS (for a wiki or a blog), a blockchain/cryptocurrency client (for Dogecoin for example), an emulator/simulator for some hardware... I can't think of anything else right now.
Roy Batty · 2018-01-06 23:38
I started doing K&R and realized how dumb I am in the process, and that KISS is easier said than done. For example, I did problem 1-22 (https://gist.github.com/anonymous/9ae179b59916728d7b1d8cfb97e5b066) and then looked online for solutions to see how mine compared--sweet baby Jesus. Because I don't have one iota of intelligence, I didn't make the program find the nearest space to the fold point to be used as the reference to insert a newline. Instead, I used a stupid, circumlocutory way via detecting words in the input line. Then there's also the fact I decided to use a constant to determine the fold length and some other stuff in a similar vein. Anyway, besides the aforementioned issues, is there anything else wrong my soykafpile?
Motoko Kusanagi · 2018-01-07 10:26
>>6026 I don't have time to look through it properly right now. There is such a thing as a bool type which you can include from stdbool.h. >looked online for solutions to see how mine compared--sweet baby Jesus. You are not stupid and everyone else is not a genius. Those other people are building on top of each other. They didn't figure this all out themselves. A lot of it is just about having experience.
Agent Richard Gill · 2018-01-07 15:29
I need to write a milter for postfix that changes the sender's address if the recipient meets certain conditions, it's nothing complicated I didn't find much online about milters, where can I get a good documentation? Basically I'm starting from zero. There is an interesting project of a milter written in python https://github.com/jmehnle/ppymilter
Unspecified · 2018-01-09 05:01
In c, I there a way to add to an array in series? Like ad X to Array[0] then to Array[1] etc but all of that with a single statement or operation.
Drano · 2018-01-09 12:08
>>6046 To clarify, you want fill the entire array with one thing?
Roger Pollack · 2018-01-09 13:02
>>6047 Not him, but I think what he wants is this, but in one statement instead of a loop. for (int i = 0; i < nelem; i++) array[i] += k; I think if you use #pragma omp simd with -fopenmp then it should work, but I really have no idea. Might need to make k const
Dox · 2018-01-09 13:51
>>6049 You're right. My reading comprehension is soykaf.
Miho Iwakura · 2018-01-09 19:13
>>6047 Its more complicated My array starts with all zeros but I want array[0] to be 1 and array[26] to be 25 >>6049 This is too advanced for me
Dox · 2018-01-09 22:19
>>6056 Think about whether you need an array at all. If you have an initialization loop that assigns a trivial computation to array[index], like the identity function, and a usage loop that does something simple with array[index], you can dump both the array and the initialization loop, and in the usage loop substitute the lookup of array[index] with the expression that you would have stored into array[index] in the initialization loop.
Tyrell Wellick · 2018-01-10 00:42
>>6057 I have to sue an array, the exercise requires it. I posted an earlier version of my program here >>5974 not much has changed
Shogun · 2018-01-10 04:28
Is that Stallman? What the fuarrrk is he sitting in, some kind of stoned design major's bus stop?
Junichi Fujiwara · 2018-01-10 12:06
>>6059 Going by the description you give and the mandatory use of an array, I surmised these steps: 1. Ask for input from user 2. Assuming you receive an 'a', fill the array (string) with the alphabet 3. Print string and thus the alphabet Is this what you're trying to achieve? Because if so, using a loop to achieve step two is the probable method the writer of the exercise wants you to use.
Debbie Charteris · 2018-01-10 13:32
Hello, as a part of my current toy project I want to build a library for managing memory in safely C. void *safe_malloc(size_t size, void (*alert)(char *message)) { char msg[] = "Could not allocate from the heap!\n"; void *ptr; if ((ptr = (void *)malloc(size)) == NULL) { (*alert)(msg); return NULL; } else { return ptr; } } Is that function covering every failure cases of the malloc function ? Are there any other verifications to perform ?
cdr · 2018-01-10 21:35
>>6062 Yes to all of that, I assume I Must use a loop because I also learned about loops in the same chapter but I dunno what specific loop to use
Yet Another Lainon · 2018-01-10 22:14
>>6060 >working on laptop -> laptop images -> https://www.stallman.org/photos/rms-working/ -> find image -> https://www.stallman.org/photos/rms-working/pages/123.html -> view metadata -> 2010-11-18 -> ${SEARCH_ENGINE} -> was in Armenia -> Armenia images -> https://www.stallman.org/photos/armenia/index.html -> find in to-geghard -> https://www.stallman.org/photos/armenia/to-geghard/index.html It is located on the road to Geghard monastery, a UNESCO world heritage site in Armenia. https://en.wikipedia.org/wiki/Geghard >But what is it? That is a question for the ages. Only a hero without peer will wrest this information from the jaws of the Profound Darkness and bring light to Algo.
Six · 2018-01-10 22:27
>>6066 You can choose any loop variation and achieve the same result, but usually one would use the for loop when iterating through an array; which is mandatory to consummate step 2.
Trinity · 2018-01-10 23:52
>>6063 You can do `man 3 malloc` to see all of its failure cases, but yeah I think you've covered them all
Dox · 2018-01-11 06:18
>>6068 This is what my program looks right now /*array of 26, all the alphabets letters and prints them*/ /*a = 97 z = 122*/ #include <stdio.h> #define alph 26 int main(void) { char strng[alph]; printf ("type 'a' and get the alphabet "); scanf (" %c", &strng); for(strng[0] > 97; strng[25] < 122; ++strng) //the compiler won't let me use ++ { printf ("%c", strng); } return 0; } I'm unsure if my loop will work, my issue is how can add to the array properly since ++ isn't working.
Rick Deckard · 2018-01-11 11:23
>>6073 You have already been told in >>5987 why ++ won't work, and that you should go through your array with an index. >for(strng[0] > 97; The first part of a for loop header is for initialization, not condition testing. Search for "C for loop array" and look at a random result, e.g. https://beginnersbook.com/2014/01/c-arrays-example/
Arisu Mizuki · 2018-01-11 12:51
>>6073 Out of curiosity, lainon, what book or website is this example from?
Erik Johansson · 2018-01-12 04:56
>>6087 Well that goes back to my earlier question, if ++ doesn't work with the full array how do I index the individual elements? I don't think I been introduced to indexes yet >>6091 the c language primer, first exercise of the 6th chapter
Unsigned · 2018-01-12 11:57
>>6111 >the c language primer, first exercise of the 6th chapter By any chance, did you actually mean this: """Programming Exercises 1: Write a program that creates an array with 26 elements and stores the 26 lowercase letters in it. Also have it show the array contents.""" from "C Primer Plus" by Stephen Prata?
Pris · 2018-01-13 02:59
>>6116 exactly that I always mess up the title of the book but its exactly that
Tank · 2018-01-13 12:32
>>6111 >>6130 >exactly that The exercise doesn't ask you to get any input from the user, so you can dump the prompt and the scanf. >how do I index the individual elements? I don't think I been introduced to indexes yet In chapter 6, right after the section named "Introducing Arrays", there's a section named "Using a for Loop with an Array". It contains "Listing 6.19. The scores_in.c Program" that starts with the comment line "// scores_in.c -- uses loops for array processing". It uses this loop three times: for (index = 0; index < SIZE; index++) The subsequent discussion includes the following paragraph: """Second, the idiom for (index = 0; index < SIZE; index++) is a handy one for processing an array of size SIZE. It's important to get the right array limits. The first element has index 0, and the loop starts by setting index to 0. Because the numbering starts with 0, the element index for the last element is SIZE - 1. That is, the tenth element is score[9]. Using the test condition index < SIZE accomplishes this, making the last value of index used in the loop SIZE - 1.""" Use two loops like the one shown, one to initialize your array with the lowercase letters and one to print out the array elements.
Roger Pollack · 2018-01-14 21:45
Did someone read pic related? Is it good and/or still relevant?
Nobody special · 2018-01-15 15:53
>>6163 I'm reading it now. It's good for fundamentals and UNIX philosophy, but should probably be left for after you can already get around in UNIX since it's outdated.
Just another Random Lainon · 2018-01-15 19:58
>>6182 Thanks, lainon. In your opinion, what are things a daily, ~intermediate level UNIX user can still learn from it today?
nil · 2018-01-15 22:04
>>6193 >I keep getting undefined for test[i] >function(i) >call without arguments
quote · 2018-01-15 22:32
I'm getting the error 'httpRequest is not defined' in my console, but I'm not sure why since I'm invoking the makeRequest function. I will appreciate help with this.
Church · 2018-01-15 22:50
>>6199 `httpRequest` only exists in `makeRequest`, `streams` won't see it. You are also invoking them in the wrong order. Additionally, there's nothing guaranteeing that `streams` won't simply run, doing nothing, before the request is completed. Why not invoke it as an event handler instead?
Nobody important · 2018-01-15 23:09
>>6200 >>6200 >>6200 I'm immediately invoking makeRequest now and I moved httpRequest outside of makeRequests scope. I still get the same error. I tried making httpRequest = new XMLHttpRequest(); outside of the scope of makeRequest too, and then all I got was my console.log ('test'), but no json response object. I don't think I need an event handler besides my eventlistener for the Dom to load since streams only works when the httprequest is finished.
Switch · 2018-01-15 23:25
>>6204 nevermind, I got it to work. I had to use this in streams() function instead of httpRequest. Thanks for trying to help.
() · 2018-01-16 05:32
>>6135 I get the idea but I can't express it in code properly, maybe I should restart with a different design I really wish I had somebody to teach me and correct me instead of posting here.
Faye Valentine · 2018-01-16 06:35
>>5824 How do i get a good practical understanding of CS? What books to read what to study. What are the fundamentals i should know.
Cutter · 2018-01-16 08:43
>>6212 The Art of Computer Programming, Donald Knuth and practice above all else
John Titor · 2018-01-16 16:21
>>6209 You're over-complicating it, lainon. You should re-read that section or the whole chapter if you're having trouble with the implementation.
Zero Cool · 2018-01-16 23:47
>>6222 Yes I will try rereading the book and redoing the program. Still for me its really hard since I have a background in humanities and C is my first language and its a really shocking change going from one thing to the other because you need a really different way of thinking and doing.
HELIOS · 2018-01-17 01:20
>>6215 Thank you for the advice!
Case · 2018-01-19 20:20
I have two functions with two different ajax request url's. one function (streamers) has the class .gamers that I want to select in my streams function so that I can add the html I made from the streams function inside of the .gamers class. When I try to do this inside of the streams function with querSelector('.gamers') I get a reference error, and I tried making the streamers function pass it as a parameter to the streams function but I just got back some xmlhttp object, not the html selected. I would appreciate if anyone can help me with this. Here is the code : https://pastebin.com/M9LEnhNz
Naomi Nascimento · 2018-01-19 20:37
>>6236 It'll just take practice. Once you grasp the basic concepts of programming and C, you'll have little trouble completing the book. Good luck!
Anonymous · 2018-01-20 00:22
>>6290 Your code doesn't show your actual attempt to get '.gamers', your post doesn't show the precise error message, and you are not controlling which callback gets called first. Also, when two functions only differ in minor details, you should probably factor that out rather than paste text blocks around.
Neuromancer · 2018-01-20 10:27
I want to write my own vim-like editor in C++. How do I begin? Many sites recommend ncurses. Is there anything better for C++ or is ncurses the de facto? Please provide some links and/or books. Thank you.
car · 2018-01-20 18:08
>>6308 >I want to write my own vim-like editor in C++. Why? If it's because existing editors are missing a feature you want then it would be better to extend an existing editor. If the purpose it learning then asking how to do it defeats the point.
Donna Hawthorne · 2018-01-20 21:20
Is pic related still reliable ? It's been released in 2005 with now newer edition.
Trinity · 2018-01-20 21:23
>>6308 ncurses is fine but you might want to start from scratch by learning how ncurses work and implement only the prts you need.
Lady 3Jane.. · 2018-01-20 22:07
>>6324 Most people just debug with print statements.
queue · 2018-01-21 00:55
>>6327 No no no no no no. Do not do this. Debuggers are faster, don't require compilation, and allow for on-the-fly memory examination and editting, which is paramount to detecting bugs efficiently Learn to use a debugger. I don't know about the book in question, but gdb hasn't changed much over the years afaik so it's probably still good. There's a lot of GUI interfaces to it that help, too.
Lady 3Jane.. · 2018-01-21 10:42
>>6328 >Debuggers are faster, don't require compilation, and allow for on-the-fly memory examination and editting, Debuggers work by inserting breakpoint instructions into your code which trigger an interrupt which returns control to the debugger which will replace the breakpoint with the original instruction and wait for you to decide what to do next. Even if your action is scripted, a debugger cannot possibly be faster than logging. Debuggers are only really useful in a limited number of situations like getting a stack trace from native code or analyzing a core dump you can't recreate. But you can learn how to use a debugger as and when you need it. Reading a whole book about it is dumb.
roll · 2018-01-22 05:05
Lain do you suggest advancing your knowledge in programming by taking MOOCs or reading books/doing stuff by yourself? Also general thread about learning to program
Iverson · 2018-01-22 05:29
>>6347 I've never really tried following a MOOC but I think trying to learn things by yourself is more efficient. In order to learn how to do something you just have to find an interesting project that requires you to have the necessary knowledge. For example, when I decided to learn assembly I decided to create a JIT compiler for a small programming language. I feel like staying motivated is way easier when the knowledge you want to absorb is a means to an end rather than the end itself.
Switch · 2018-01-22 05:30
Huh, I've never heard the term "MOOCs" before. I've been learning programming for the past 10+ years so I've always just stuck to books. They've worked well, and when I get stuck I join an IRC/telegram/subreddit/chan dedicated to programming and talk about it there until I'm motivated again. I've taken one "MOOC" on Udemy for HTML5/JavaScript/web front end development and enjoyed it a lot, but it was a "learn whenever you want" kind of class, not really anything structured, nor did it have tests or anything.
Case · 2018-01-22 14:49
What course or book would be good for learning to program? Also a math book to go along with it?
Apoc · 2018-01-22 17:10
>>6340 >Debuggers work by inserting breakpoint instructions into your code which trigger an interrupt which returns control to the debugger which will replace the breakpoint with the original instruction and wait for you to decide what to do next. Even if your action is scripted, a debugger cannot possibly be faster than logging. I know the debugger in question is GDB, but not all debuggers operate on this principal. I've always thought of debugging as an interactive process and so don't see why speed would matter. >Debuggers are only really useful in a limited number of situations like getting a stack trace from native code or analyzing a core dump you can't recreate. But you can learn how to use a debugger as and when you need it. I've noticed that many languages don't have good debugging solutions, which seems to be why people using printing and other poor means. A language with a good debugger is so pleasant compared to simply thinking about that. >Reading a whole book about it is dumb. If they're going to read a whole book about GDB, they should at least buy the official FSF manual.
The Fin · 2018-01-22 18:41
>>6355 >I know the debugger in question is GDB, but not all debuggers operate on this principal. Nothing to do with GDB. This is how native code debugging works with any debugger on any processor. Do you think it's all just magic?
Turner · 2018-01-22 23:02
I have two ajax requests, and in the second one that calls the stream function, I am supposed to have users html updated with either online or offline. Currently only whatever last user that loads from the ajax requests's html is updated to either online of offline, and then the console shows that div (the html element that I want to update) is unefined. I will appreciate help with this. only the last user id html that is returned from the ajax request is updated with either online or offline, while the rest of the users html are blank and the console shows div is undefined. link to code: https://pastebin.com/02u43iHK
Wirth · 2018-01-23 00:56
>>6363 Inside streamers, you are calling makeRequest2 for the first time with proper arguments but before the function is even defined, and then a second time after the function is defined but without arguments, so the username and div parameters inside makeRequest2 will be undefined. On the plus side, your callback sequencing is now correct.
Liet Kynes · 2018-01-23 01:34
>>6366 I fixed that and now I'm only calling makeRequest2 once with the arguments usernames and div passed into it to go to the streams function. I'm not getting any error in my console now, but only the last streamers ajax call that is requested html is updated, I don't know why or how to fix. function getStreams(){ let url = [ 'angryjoeshow', 'eleaguetv', 'destiny', 'blusewilly_retry', 'dsfsd']; (function makeRequest(){ url.forEach(function(e){ let httpRequest = new XMLHttpRequest(); if(!httpRequest){ alert('can not create http instance!') return false; } httpRequest.onreadystatechange = streamers; httpRequest.open('GET', 'https://wind-bow.glitch.me/twitch-api/channels/' + e, true); httpRequest.send(); }); })(); function streamers(){ let data; if(this.readyState === XMLHttpRequest.DONE){ if(this.status === 200){ data = JSON.parse(this.response); let username = data.name main.innerHTML += ` <div id='${data.name}' class ='gamers'> <a href='${data.url}' target='blank'><img class='logo' src='${data.logo}'></a> <h4 class='streamer'>${data.display_name}</h4> </div>`; const div = main.querySelector(`#${data.name}`); function makeRequest2(username, div) { let httpRequest = new XMLHttpRequest(); if (!httpRequest) { alert("can not create http instance!"); return false; } httpRequest.onreadystatechange = function() { streams(this, username, div); }; httpRequest.open("GET", "https://wind-bow.glitch.me/twitch-api/streams/" + username, true); httpRequest.send(); } makeRequest2(username, div); } } } } function streams(httpReq, username, div){ if(httpReq.readyState === XMLHttpRequest.DONE){ if(httpReq.status === 200){ let data = JSON.parse(httpReq.response); if(data.stream === null){ let offline = ` <p class='offline'> offline </p>`; div.innerHTML += offline; }else { let online =` <p class='online'>${data.stream.game} <span>online</span> </p>`; div.innerHTML += online; } } } }
cdr · 2018-01-23 02:03
>>6367 nevermind I got it. in streams funciton main.querySelector(`#${username}`).innerHTML += offline; replaced with div.innerHTML works.
Unsigned · 2018-01-24 06:16
>>6358 I'm accustomed to a Lisp debugger, so it's not necessarily native nor does it necessarily operate on that principle. You've encouraged me to dig into the internals of the SBCL debugger; I may later return to tell if it uses breakpoints, signals, or some other mechanism.
if · 2018-01-24 11:41
>>6367 >only the last streamers ajax call that is requested html is updated, I don't know why To add to the fix in >>6368, the explanation appears to be that when appending directly to innerHTML, all of the element's content is rebuilt, including already present children, so previously saved divs will no longer be part of the document. https://stackoverflow.com/questions/18539992/innerhtml-append-instead-of-replacing https://stackoverflow.com/questions/6304453/javascript-append-html-to-container-element-without-innerhtml
Cereal Killer · 2018-01-24 19:38
Is AI a meme? Will learning Lisp pay off?
Incognito · 2018-01-24 23:08
>>6394 >Is AI a meme? Artificial Intelligence tends to go by the name Machine Learning these days. >Will learning Lisp pay off? The only thing Lisp is good for in 2017 is earning internet cool points.
Unsigned · 2018-01-24 23:31
>Incognito 2018-01-24 >The only thing Lisp is good for in 2017
Drano · 2018-01-25 00:52
>>6394 >Is AI a meme? Real AI isn't going to exist any time soon, unless some governments already have it. None of the trash being peddled by companies is close. Symbolic AI is already used to great success and a human being can understand how it works, but machine learning is silly to me and results in incomprehensible messes. >Will learning Lisp pay off? Lisp isn't useful solely for AI. Learning Lisp is good if only so you learn about what other languages lack.
Lain Iwakura · 2018-01-25 01:04
>>6400 >machine learning is silly to me and results in incomprehensible messes What is bad about this when the original data was already that way? Machine learning shines in cases as seperating 20dimenional data into groups. A normal person won't be able to do that. Why should the same person understand the machine output then if they can't solve it themself? You may understand the algorithm and verify that the result works but you shouldn't expect more.
SHODAN · 2018-01-25 06:23
So I've continued working on that exercise from the c primer plus I overhauled the program and think I have something workable now #include <stdio.h> #define Alph 26 int main (void) { int refe; char string[refe]; //add more variables, maybe using them on the loop refe = Alph; //This isn't need. is it? for (string[0] = 97; string[25] = 122; refe++); printf ("%26c", string); return 0; } So far this iteration compiles, runs but only prints a bunch of spaces and a non alphabetic character, I'm probably not initiating the loop correctly. >>6354 What language do you want to learn? Also math isn't really need if you did good on high school
nil · 2018-01-25 13:12
>>6404 First of all, refe is uninitialized and so it's some random value. It could be zero, it could be negative, it could be 2.1 billion. You need to set something like `int refe = 26` or move the `refe = Alph` line above the declaration of `string`. Your for loop condition is an assignment. It will always return the result of the assignment, which in your case is your hardcoded 122. Since 122 is not zero, it's considered true. Think about expanding your for loop into a while loop, it would look like this string[0] = 97; while (string[25] = 122) { // loop condition is always true printf("%26c", string); refe++; } So you only assign two letters of your string (the first and the last). You increment refe but you never use it. Also you always print the same thing each time in the loop. Now onto your printf statement. If you want to print the whole string you need a 's' instead of a 'c'. 'c' is for a single char. 26 is the width specifier, which means "make this field at least 26 characters wide when I print it". As for the non-alphabetic character, that's because you're telling printf that `string` is a character, when really it's a pointer-to-character, so it's using garbage data from the low bits of your pointer. If you change the c to an s in the format string it'll look right. Even if you fix all that, it's still not going to do what you want. Rethink your logic.
setq · 2018-01-25 16:03
>>6404 In addition to what >>6409 said, make sure to null-terminate string (i.e. add '\0' at the end of it.) if you're going to print string all at once via printf("%s").
Anamika · 2018-01-25 17:03
what do I need to learn in order to make an application such as spotify? What kind of programming languages?
Hitomi · 2018-01-25 17:18
>>6412 >what do I need to learn in order to make an application such as spotify? Effort. >What kind of programming languages? The kind you can learn http://www.catb.org/esr/faqs/hacker-howto.html
Milner · 2018-01-25 21:58
>>6413 What does it actually mean, wise one?
Gyula Kovacs · 2018-01-26 04:28
>>6409 >>6410 Thank you. Going with your examples the program compiles but runs printing the non alphabetic character over and over again. I will have to meditate and rethink the program once again, sadly I dunno what to do at this moment — give me advise.
J.C. Denton · 2018-01-26 13:10
>>6418 That wasn't an example for you to follow. It was simply the original code rewritten in a more readable format so you could see what you're doing wrong logically. You still need to assign every char in the string, and you still need to print strings using %s not %c.
Cypher · 2018-01-28 02:00
>>6419 Well fuarrrk, I'l rework more of the program again.
Aristóteles Amadópulus · 2018-01-28 22:01
Hello, I'm a beginner interested in making a simple script that works on 4chan that allows me to click a button or something that will open whichever thread I'm on in an archive site. So I'm here to ask how I should be going about learning to do this? I don't really know what to search up so I can find something relevant to what I want to do.
Leto Atreides I · 2018-01-29 00:54
>>6457 Learn javascript (https://developer.mozilla.org/en-US/docs/Web/JavaScript) and read up on userscripts. Those are your tools; once you known them you'll be able to easily figure it. If you get stuck, 4chanx provides the functionality you want to implement.
quote · 2018-01-29 21:26
This'll sound stupid because I don't know the correct terminology and I should really know how to do it if I'm asking in the first place. I want to set up a LAMP stack which is fine but how would I set it up in such a way that the system packages are separate from the stack packages? As an example, in Python you can use venv to set up what I'm after. With venv I could have one version of scipy or whatever installed locally and another installed only within that environment. How would one do this with PHP? From googling it looks like docker or vagrant might be what I'm after but I'm in over my head here. Thanks.
Jane Doe · 2018-01-30 22:42
>>6465 Preface here that I have only thought about your question for two minutes. Docker would be the solution I use for this. You could either pull the lamp stack docker image https://hub.docker.com/r/fauria/lamp/ Or write a docker-compose file that launches them all as separate containers. A docker-compose file is just yaml that defines what the containers run and which ones they link to. I would do option two. Just one container running Apache, one container running mariadb, and one that runs php. Then whatever it is you are trying to host, I would make create a volume (essentially a symlink) between the physical machine and the containers. So for instance if whatever it is in /var/www -- you can tell the apache container to use the local /var/www/ within the container and go. Hope this helps lainon
Yet Another Lainon · 2018-01-30 23:30
>>6480 Thanks man, it sounds ideal.
Nanashi No Gombe · 2018-01-31 05:19
I'm sorry but I'm still stuck in the same problem from the c premier plus, you people must be getting tired of me, Right now everything boils to for example; how do I take an array, give the first entry a value of 1, the second entry a value of 2 and so on until reaching the last entry giving it the desired value? I think I have to make a function but I have no idea how do functions interact with arrays.
stack · 2018-01-31 12:46
>>6488 for (int i = 0; i < length; i++) { my_array[i] = i + 1; } note the (i + 1), the first index of the array is zero, so tho put a 1 at position 0 I fill it with (position + 1) or in this case (i + 1). You can do it with or without creating a function. Passing an array to a function decays into a pointer to the first item, so you may want to hold off on that until you have the basics down.
William Holtzer · 2018-01-31 20:46
how to learn computer science math from absolute newbie in math?
Dr. X · 2018-02-01 00:35
>>6513 I was writing a post about it and then I just saw your reply. Are you in my mind or something? This soykaf scares me. So, I've watching Youtube videos about the basics and then I chose a book called Fundamentos da Matemática Elementar (vol 0), by Rufino. I think it is a good one, but sometimes it get very complex for me, since I have never studied math from a formal book. By now I'm wondering about studying logic before entering into math, do you guys think it would be a good idea? My level is almost zero, I learned how to to divide real numbers last week. The book is in portuguese, I decided to use books written in my native language (I'm brazilian) because I'm not sure if my English is good enough for it (It's hard to understand in my own language, so how hard would it be in another one?), and my russian just is like kicking dead whales down the beach. Even so, I would appreciate any book recommendation, either it is on English or any other language. If the book really worth it, I can simply use good translator. I've seen some people saying that Indian books are great.
setq · 2018-02-01 01:56
>>6519 Would you want to talk? I could help you if you need :3 Got a signal, wire, tox, or anything?
Incognito · 2018-02-01 08:04
>>6521 Sure. Thanks. My Tox: 9762FCA553CEE0F1BB33719F7CC1F5A20A7B12A9D5FFDA14679D6878865C42626C58ACBD8730
Meddler · 2018-02-01 15:07
>>6412 If you just want to make a music streaming program then lookup libraries which do this. You'll find a hodge-podge of libraries you'll need -- reading an MP3, server library allowing connection on a port, streaming library for data over a port -- and it'll be your job to put them all together. If you actually want to compete with Spotify, look into getting yourself a job making lots of money with lots of connections so you can strongarm negotiations with record labels so you can get paid for streaming content you did not create.
Elliot Alderson · 2018-02-01 21:54
>>6497 I made a new program based on the example you gave me, it runs but still returns gibberish, I experimented making it print the numeric values it had instead of a text string and it prints a negative number. There are still some things I'd like to tinker with before giving up again.
Dr. X · 2018-02-01 22:02
>>6480 Finally got round to trying this out, I'll stick with a single container while I get my bearings but I am interested in having multiple containers. What are the advantages of having a container for each service over one for everything?
Nguoi La · 2018-02-02 01:32
>>6531 Added ya! :)
Lunch · 2018-02-02 19:03
I have a question about inter-process communication! I'm currently building a prototype for software that will be used to display a stream of incoming information in a readable manner. I do not have access to that stream of data, so I figured that I would build the main program much like a server, and a client program that would act as a REPL of sorts so that I can type the "stream of data" in one window and watch the main program change interactively in another. I figured sockets were the way to do this, so I set up the client to send data to the main program, and the main program receives that data. It works perfectly, except that when the client closes, the server closes as well. This was very unexpected behavior, because the server logic is in an infinite loop that sleeps 1/15th of a second each iteration. I'm not forking the main program when it accepts the connection from a client, and (if I'm understanding the literature correctly) that's the reason why my main program is closing. Forking the process and having the child communicate to the parent seems like a clunky solution. Are sockets the right thing to be using for a situation like this, where I only really need one client to be connected at a time? Any suggestions on how I should proceed?
Molly Millions · 2018-02-02 19:44
>>6599 If everything is on the same machine then a named pipe might be more suitable. Also called a fifo. https://linux.die.net/man/3/mkfifo
↑ · 2018-02-03 02:34
Complete new user here, I'm learning C++ as a requirement for the degree I am taking. Today in tutorial we had the following(albeit in a soykaftier style) program given to us and the TA asked what the output would be. Now logically I understand that float and double are stored with different precision and therefore should not be equal to each other in this case. But when he displayed it on the screen without output I quickly copied it down just to check and was presented with the result that they are in fact equal. I asked him why and if there was perhaps an optimization occurring but of course he had no idea how to answer. Maybe someone here can do a better job for me, thanks! ~>> cat a.cpp; c++ a.cpp -o a; echo "\n"; ./a #include <iostream> int main(void) { float x = 0.5; double y = 0.5; if (x == y) std::cout << "Equal\n"; else std::cout << "Not equal\n"; std::cout << "x: " << x << "\ny: " << y << std::endl; return 0; } Equal x: 0.5 y: 0.5
Torvalds · 2018-02-03 04:13
>>6618 0.5 is 1/2 is binary 0.1 exactly. No loss of precision.
Otto Normalverbraucher · 2018-02-03 05:29
>>6625 While I appreciate the reply it doesn't seem to address the issue I raised(at least from the perspective of a noob). If these are different data types then why do they hold the same value. As I mentioned the instructor seemed to think that they don't and it does have me questioning his credibility. As I suggested before, does this come down to the compiler optimizing the program so that the double is not using any extra memory then it needs? If so I can assume it equally applies to the float. If this is the case though does that mean that the only point of a using one particular data type over the next is to limit the precision to a maximum length?
Lady Jessica · 2018-02-03 11:13
>>6626 >If these are different data types then why do they hold the same value. >>6618 >float x = 0.5; >double y = 0.5; == between a float and a double tests for equality of the mathematical values they hold, rather than of the internal representations they use to store those values. The latter differ but the former match, because both are able to represent 1/2 exactly. >the instructor seemed to think that they don't Their internal representations differ but their mathematical values are equal. >does this come down to the compiler optimizing the program so that the double is not using any extra memory then it needs? No. It uses the same fixed size regardless of value. >the only point of a using one particular data type over the next is to limit the precision to a maximum length? The point is that you have a storage space versus precision tradeoff available to you that you can decide based on the requirements of the particular situation.
Colmerauer · 2018-02-03 14:00
>>6626 What >>6635 forgot to mention is that when comparing equality, the compiler will convert the values up to the largest type it needs. So checking float == float will perform no conversion, but float == double will promote the float to a double. Same with float == int, the int will be promoted to a float. It is not comparing the in-memory values. If you wanted to do that, you'd have to do something like memcmp(&x, &y, sizeof(double)); which would undoubtedly tell you that they're different
Ein · 2018-02-03 16:02
>>6635 >Their internal representations differ but their mathematical values are equal. He had this exact test on the board and asked what the output was. (His answer was "not equal") >>6638 In any case, thanks both of you. That makes a lot more sense now.
Koichiro · 2018-02-05 19:04
Excuse me for a dumb question lainons. I've been unable to connect via Wi-Fi in Debian. I've recently installed it. It seems that there a lot of firmwares missing. How do i download and install them? I'm not used to all this computer magic but i am willing to learn.
Roger Pollack · 2018-02-05 19:25
>>6712 Ask your favourite search engine "[your pc model] wifi driver debian"
Armitage · 2018-02-05 21:44
>>6712 you probably have to enable non-free and contrib repos in your sources.list. then you just apt-get update and then install firmware-linux package. if that doesn't include your drivers, then just search debian package archive or use search the web, as >>6714 said
Jane Doe · 2018-02-05 22:28
>>6712 Proprietary firmware is in the non-free section, which you have to enable in your package manager's settings. Refresh the package list and install the firmware-* package that has your card in its description. If you don't know what card you have open a terminal and run lspci | grep -F 802.11
Crazy Jake · 2018-02-05 22:38
>>6717 I ran the command and now i know my Wireless adatper is this one: Qualcomm Atheros QCA9377 802.11ac Wireless Network Adapter Altough, I still don't know what to do. How do i find the firmware for this?
Miho Iwakura · 2018-02-05 22:42
>>6718 OK, now i found this https://packages.debian.org/stretch/firmware-atheros But I still don't know how to use it to fix my problem.
Nell · 2018-02-05 22:45
>>6718 >>6717 I'm slowly getting the hang of it. What is aptitude? And what is Synaptic?
Unknown · 2018-02-05 22:49
>>6720 I've wrote this on the sources.list: deb http://ftp.de.debian.org/debian stretch main non-free I hope it works.
Kay · 2018-02-05 23:53
>>6721 It worked yet i don't know why. Some kind of magic happened here.
Batou · 2018-02-06 01:12
>>6720 >And what is Synaptic? Synaptic is one of the package manager frontends. You can use Settings -> Repositories to manage your repositories -- such as adding non-free to Section(s) -- without having to manually edit sources.list. You can then press Reload and install firmware-<yourcard> from the package list. Don't forget to Apply.