« first day (117 days earlier)      last day (3512 days later) » 

3:00 AM
Hey girls.
I've got a question about Buffer's and the heap. My Objc book just introduced me to malloc, to allocate memory for use. But what happens if I ask for more memory than the system has? I've only got 2Gb of RAM on this system.
 
3:14 AM
Can someone explain what this statement does specifically? I'm having trouble understanding some of the syntax
**Info**
*Person* is a struct with two floats.
Person *A = (Person *)malloc(sizeof(Person));
My interpretation is that a Pointer is being created for "A", and the target address is a buffer that is the size of the struct. However, what does: (Person *) before malloc mean?
Why do we change attributes like: A.variable to A->variable when addressing local variables inside the struct?
 
 
2 hours later…
ASR
5:13 AM
Hi all good morning
 
@Owatch on error, for example there is no more space in dynamic memory --- malloc() returns NULL. So, You should always check it's output :}
helloc ASR; // morning :}
 
ASR
@Kamiccolo hi
I am teaching java to my brother, he don't know any thing about OOPS Concepts, he can easily forgetting every thing i want to say OOPS concepts to him like a story so he can't forget.
Can u suggest me any thing, how to say OOPS concept?
 
@Owatch both -> and . are struct member selection operators. Only thing if we're accessing by pointer --- using ->, if not --- .
@ASR hmmm... usually OOP is one of those barriers You have to overcome leaning new language :} how old is he? :}
 
ASR
He just completed his Bachlors degree
@Kamiccolo can u tell me how to explain encapsulation with real world example?
 
5:39 AM
HELP
 
@ASR DON"T use real world examples :} it just messes with Your head! Instead You should try applying real programming problems and how to solve them with OOP, not real world examples.
@Donnie hoy :} what kind of help are You seeking?
@Owatch and * in Your case informs compiler that we're declaring pointer to a Person. Btw, it's not recommending using typedefs in this case. So, leave it be "struct person` instead.
 
math help :(
 
@Donnie could You please describe the problem? :}
 
it's a polynomial equation
 
ASR
6:25 AM
@Kamiccolo can u give me one example please ...
 
@ASR stack, deck, tree, buffer, string, hash table, whatever. What solves some real problem and can be easily written using OOP.
 
ASR
@Kamiccolo hmm ok
thank you!
is C++ is a Platform dependent or independent?
 
@ASR as a language --- independent. You're not forced to use only C++ on some specific platform, and limited to that platform only.
 
ASR
hmm ok
 
but how to write the code which is platform independent as much as possible --- it's another question.
 
ASR
6:37 AM
@Kamiccolo obviously JAV
:)
 
7:05 AM
@ASR never again.
 
ASR
why?
How can I print 1 to 100 in C++ without a loop, GOTO or recursion?
 
7:35 AM
Does metarecursion count?
@ASR?
 
ASR
yes
#include <stdlib.h>

int main() {
  /* Cross your fingers and hope seq exists! */
  return system("seq 1 100");
}
#include <iostream>
#include <stdlib.h>

int num;
void(**rptr)();

void foo() {
  if(num >= 100) exit(0);
  std::cout << ++num << std::endl;
  *rptr++ = foo;
}

int main() {
  rptr = (void(**)())alloca(sizeof(*rptr) * 200) - 1;
  foo();
  return 0;
}
 
ASR
#include <iostream>
#include <stdlib.h>

int main() {
  int x = 0;
  x |= !fork() << 0;
  x |= !fork() << 1;
  x |= !fork() << 2;
  x |= !fork() << 3;
  x |= !fork() << 4;
  x |= !fork() << 5;
  x |= !fork() << 6;
  if(1 <= x && x <= 100) std::cout << x << std::endl;
  return 0;
}
 
What the hell
Give me am hour I'll do the meta version
 
7:58 AM
helloc all;
@Owatch sorry?
you are at the wrong place :P
@Kamiccolo what about virtual memory?
there's still some memory in the hard disk :D
 
@ASR here, printing 1-10 without loops/goto/recursion.
 
@Apoorv I suppose, Operating System deals with that in mysterious ways automagically :} If You have some Swap space dedicated.
 
8:13 AM
Also you haven't forbidden hardcoding :p
 
@ASR use std::generate ? :}
 
@Kamic why not simply iota then?
 
@BartekBanachewicz oh, this one is even simplier!
@BartekBanachewicz only thing that You can provide generation function to std::generate to be able to print everything nicely without loop.
 
8:29 AM
helloc all
 
helloc @mantal;
 
@Kamiccolo you can print from iota too?
@Kamiccolo you don't need a loop
 
helloc @mantal
 
@BartekBanachewicz You tell me, I'm not into C++ at all xP
 
9:02 AM
@Kamiccolo sec
 
9:15 AM
@Kamiccolo appears I might have been wrong. generate_n is an easier way to do it :S
 
9:44 AM
@BartekBanachewicz that was my first impression :} But... as I said...
uh... CodeProject become such a stinking cloaca... :( half of the posts --- how bad is Android, Linux, etc. another half --- how inovative and grand Microsoft is.
 
@Kamiccolo i guess you visited the website after a long time
cause it is like that from a long time
 
@Apoorv It's from mails they send me daily for last... 5 years? or since the beggining of their existance :}
 
code project came into existence in 1999 i believe
 
10:00 AM
I was in secondary school than found them. So, I guess... around... 2005-tish.
mm... but there used to be lots of in death assembly articles, C for Linux, expert security, etc. And now it's just pile of sucky crap :|
 
@Kamiccolo its been the latter since i've known it :)
which is not very long ago :P
Its hard believe that it was once a gold mine
 
@Apoorv my point of view definitely changed, but I still remember those more interesting topics and how much more in depth those articles were...
Adding `str*()` to glibc:
http://lwn.net/SubscriberLink/612244/3dc61efaaca6569c/
 
10:38 AM
> This is horribly inefficient BSD crap. Using these function only leads to other errors. Correct string handling means that you always know how long your strings are and therefore you can you memcpy (instead of strcpy).
Beside, those who are using strcat or variants deserved to be punished.
lol what a fucking idiot
 
11:23 AM
> what the glibc developers would recommend for safe, fast, and simple string handling for C programs.
lol, not C
this is hilarious.
The last sentence is the best
> But there will be a lot of C code out there for a long time, so there will be a lot of string-handling bugs as well, regardless of whether strlcpy() is used
 
user3079266
11:56 AM
helloc all;
 
helloc @Mints97;
 
user3079266
'sup?
 
Busy lately, my brothers wedding is this weekend
you
 
user3079266
testing an interesting method for a potential stack overflow in C
 
12:02 PM
helloc @RonniSkansing && helloc @Mints97;
@RonniSkansing woohoo, so cool! Unless... he's marrying his Steam machine xD
 
@Mints97 heh, You might find this simple RE job interesting: erenyagdiran.github.io/… xP
 
user3079266
geez, I can't find anything on this >< Can anyone tell me if this is supposed to cause a stack overflow at some point?

void foo(char *value){
}

void main(){
while(1)
foo("very,very,verylongstring");
}
 
@Mints97 I suppose.... it's not. Because a) string is static b) function call isn't recursive
 
user3079266
@Kamiccolo so the string will always be the same string? ok...
 
12:07 PM
@Mints97 no
 
@Mints97 it wont cause a stack overflow because when foo returns it is removed from stack
 
@Mints97 string (array of char's) is statically allocated. And only thing which You put on stack is pointer to if as a parameter of function being called. After function ending it supposed to clean it's stack.
actually, not only. But it's another thing. I guess, not that important in this case: protocol of calling subroutines - what kind of registries are saved in stack, etc.
 
that's called calling convention BTW
 
@BartekBanachewicz yup, forgot the term, so made my own xD
 
 
2 hours later…
ASR
1:46 PM
Hi all !
 
user3079266
helloc @ASR;
 
helloc @ASR
 
@ASR never told me if my solution was ok :P
 
ASR
jquery-1.4.2.js , jquery-1.4.2.min.js files are the do i have to use both or only one of them is enough to use?
@BartekBanachewicz that's ok!
 
1:48 PM
@ASR you should use the min file
 
ASR
@Apoorv that is enough ?
 
@ASR neither. Use 2.x
min and normal are the same, min is just minified :P
 
ASR
@BartekBanachewicz minified means?
 
the min file has all the unneccesary whitespaces to reduce size at the cost of readability
 
ASR
minimized code?
 
1:50 PM
the other one is used for development
 
@ASR google it
 
ASR
@Apoorv ok thank u
@BartekBanachewicz hmm ok
 
even better, use the jquery library hosted by google because users might already have it cached
so it will load faster
 
ASR
@Apoorv hmm ok
thanks
 
you're welcome :)
 
 
3 hours later…
5:02 PM
Room is dead post ponies
 
user3079266
5:25 PM
lol
 
8:12 PM
helloc
I'm trying my hand at the "namespace technique" @PeterVaro explained to me; but function-pointer syntax has got me down.
IMPORT_q is supposed to be a local statically-defined void array that points to statically-defined functions in this header for controlled use in other headers.
Basically trying to model the _PyGreenlet_API here and here.
Where did i go wrong?
Going afk
(I think the chat command is sleep(Noob Saiibot), but i'm not sure :-P )
 
free @NoobSaibot;
btw, I see You've done here! MK reference xP
 
8:35 PM
helloc all;
@NoobSaibot I was talking about something like this:
/*--- functions.h ------------------------------------------------------------*/
#ifndef FUNCTIONS_H_490430285937327
#define FUNCTIONS_H_490430285937327

typedef struct functions
{
    void (*print)(int);
} Functions;

extern Functions FUNCTIONS;

#endif /* FUNCTIONS_H_490430285937327 */



/*--- functions.c ------------------------------------------------------------*/
#include <stdio.h>  /* printf() */
#include "functions.h"

static void
printer_func__(int i)
{
    printf("%d\n", i);
}

Functions FUNCTIONS = {.print = printer_func__};
although it is working perfectly, I told you earlier, I don't recommend this
it has several disadvantages -- and since C does not support name-spaces on its own, I wouldn't bother reinvent/reimplement it, as it will never be as sophisticated as it is in C++ for example
if for some reason you HAVE to use namespaces, then use C++
otherwise use straight, consistent and strict naming conventions and maybe macros, to shorten them if necessary
if you decide to stick with C
be back tomorrow ;)
goto bed;
 
8:50 PM
Hi folks, I'm just wondering if anyone has any knowledge of Arduinos here?
 
user559633
What about them @user2815547
 
I'm trying to communicate between my arduino and a computer/phone with only a photocell, headphones, and LEDs
 
user559633
Okay... So you have the arduino connected via USB or serial and you're communicating with it over a serial connection?
 
So the idea is not to use a serial connection at all
What I'm thinking of is using the headphones to power the LEDs and then utilizing the photocell to get the value of the LED
But I'm having trouble even getting the LED to power up from the headphones, so now I'm wondering If I'm even on the right track
 
user559633
wat
 
user559633
8:59 PM
are the headphones powered?
 
user559633
what voltage are you getting off of them
 
user559633
what voltage does the LED want
 
user559633
why not power the LED off of the arduino
 
user559633
so many questions
 
So I'm trying to power the headphones with the computer
the idea is
I need an input from the computer
i.e. 123
and the Arduino has to make some sort of response
 
user559633
9:03 PM
I have no idea what you're trying to do or how you expect the arduino to make a response if it only have a photocell, but unless you're somehow pulling at least a couple volts off your headphones, you're not going to power an LED.
 
sorry, let me try to clear it up a little bit. I have to come up with a way to send data from my laptop/phone to my Arduino only using parts that come with the arduino uno kit (photocell, LEDs), using earphones or microphones, and not using any wireless tech (bluetooth, wifi, RF, etc), and no serial communication
 
user559633
9:18 PM
the arduino has a USB header and it comes with a usb cable.
 
@user2815547 yup, dealing with Arduino for a while...
 
I can't use the USB
 
user559633
Can you use the GPIO?
 
So just to make our lives easier: pastebin.com/aEHGD6hs
 
user559633
Because if you can't use wireless, you don't want to use USB, and you're not willing/can't wire something up to use the IO pins, I don't know what you expect. Some sort of binary programming mode via photocell?
 
9:22 PM
Yupp. Pretty much
 
user559633
Okay, looks like you need to learn how to make a serial cable.
 
11:26 PM
@PeterVaro lol "for some reasons"
 
@PeterVaro: To hell with C++.
@PeterVaro: ...Thanks.
But i guess my real question is...
...How do malicious viruses/programmers attack running C code?
I know you can do it through user inputs
...that's one thing.
But i was reading up on the Time to Check/Time to Use Problem.
If you look at the example, the attacker injects symlink into the running setuid program.
How is this possible, and how do i defend against it?
My (naive) idea was to use the "namespace" strategy and hide everything, but that doesn't seem to make sense...
 

« first day (117 days earlier)      last day (3512 days later) »