Skip to content

Instantly share code, notes, and snippets.

View kyrylo's full-sized avatar

Kyrylo Silin kyrylo

View GitHub Profile

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.

@kyrylo
kyrylo / a.rs
Created July 20, 2018 16:34
Filters
fn main() {
let mut notifier = Notifier::new();
notifier.add_filter(|n| n.incr_count(1));
notifier.add_filter(|n| n.incr_count(1));
let mut notice = Notice::new();
println!("Before: {:#?}", notice);
notifier.notify(&mut notice);
println!("After: {:#?}", notice);
package main
import (
"database/sql"
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
~% time pry -e exit
pry -e exit 0.47s user 0.06s system 99% cpu 0.540 total
~%
~% pry --installed-plugins
Installed Plugins:
--
coolline Live syntax-highlighting for the Pry REPL
debugger Fast debugging with Pry.
debundle Allows you to use gems not in your Gemfile from Pry.
doc Provides YARD and extended documentation support for Pry
@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
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++) {