Skip to content

Instantly share code, notes, and snippets.

View kyrylo's full-sized avatar

Kyrylo Silin kyrylo

View GitHub Profile
@kyrylo
kyrylo / jsfe-1-1.js
Created December 15, 2013 15:03
JavaScript for entertainment 1. Inspired by freetonik.
/*
* By default, `eval` evaluates code in the current context.
*/
var x = 0;
function foo() {
var x = 5;
eval('x = 100');
return x;
}
% ./b-fun
vertex shader: compilation error: 0:1(10): error: GLSL 4.00 is not supported. Supported versions are: 1.10, 1.20, and 1.00 ES
tess control: compilation error: 0:1(10): error: GLSL 4.00 is not supported. Supported versions are: 1.10, 1.20, and 1.00 ES
tess eval: compilation error: 0:1(10): error: GLSL 4.00 is not supported. Supported versions are: 1.10, 1.20, and 1.00 ES

Constant lookup in Ruby can happen lexically or through the ancestry tree of the receiver(a class or module). You can identify which lookup rules are being applied by the context you're in or by the syntax being used to define a class or module.

A class body that is defined as class A::B::C; …; end will lookup constants through the ancestry tree when a constant is evaluated in its class body. Anytime you see A::B::C being used as syntax to define a class or lookup the value of a constant the ancestry tree is being used for the lookup.

16:15 → m4dm4n (~m4dm4n@gateway/tor-sasl/nongeek) has joined ##c
16:15 * m4dm4n hello everybody
16:15 m4dm4n excuse me, How can I find a C developer?
16:16 oleo by poking them with a needle!
16:16 oleo lol
16:16 ManDay by making a comment about c++ being a nice language
16:16 ManDay that will surely stirr them up
16:18 Gentle m4dm4n: produce a segfault and stare at the monitor, showing
both the code and the output. If you manage to stay completely
still long enough, they will crawl out of their holes, gather
#include <stdio.h>
#include <string.h>
struct foo { char name[32]; };
int main(void)
{
char tempstr[32];
struct foo strings[8];
#include <stdio.h>
struct foo { char *name; };
int main(void)
{
char tempstr[32];
struct foo strings[8];
for (int i = 0; i < 8; i++) {
typedef struct {
char fname[32];
char lname[32];
} name;
extern typedef struct {
char fname[32];
char lname[32];
} name;
@kyrylo
kyrylo / rfe.rb
Created August 9, 2013 23:03
Ruby for entertainment, banister's contribution.
# The `Proc#source` method is powered by the method_source gem.
$block = proc { puts "hi!" }
class Hello
def blah
binding
typedef struct {
char title[MAXTITL];
char author[MAXAUTL];
float value;
} BOOK;
typedef void (*sm)(BOOK *, BOOK, int, int);
void print_library(const BOOK *library, int count);
void sort(BOOK *library, int count, sm sorting_method);
@kyrylo
kyrylo / 14-3.c
Last active December 20, 2015 20:09
typedef struct {
char title[MAXTITL];
char author[MAXAUTL];
float value;
} BOOK;
void print_library(const BOOK *library, int count);
void sort(BOOK *library, int count, void (*sorting_method)(BOOK *, BOOK, int, int));
void alphabetically(BOOK *library, BOOK temp, int, int);
void by_value(BOOK *library, BOOK temp, int, int);