Skip to content

Instantly share code, notes, and snippets.

@eligrey
eligrey / object-watch.js
Created April 30, 2010 01:38
object.watch polyfill in ES5
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
@otsaloma
otsaloma / gist:1912166
Created February 26, 2012 01:43
Line numbers in Gtk3 text view margin
#!/usr/bin/env python3
from gi.repository import Gtk
from gi.repository import Pango
def on_text_view_draw(text_view, cairoc):
print("Drawing...")
# XXX: Rest of function not yet ported.
text_buffer = text_view.get_buffer()
bounds = text_buffer.get_bounds()
text = text_buffer.get_text(*bounds)
nlines = text.count("\n") + 1
@banaslee
banaslee / XGH - en.txt
Last active April 26, 2024 16:52
eXtreme Go-Horse Process
eXtreme Go Horse (XGH) Process
Source: http://gohorseprocess.wordpress.com
1. I think therefore it's not XGH.
In XGH you don't think, you do the first thing that comes to your mind. There's not a second option as the first one is faster.
2. There are 3 ways of solving a problem: the right way, the wrong way and the XGH way which is exactly like the wrong one but faster.
XGH is faster than any development process you know (see Axiom 14).
package sample.hello
import akka.actor.ActorSystem
import akka.actor.Props
import akka.actor.UntypedActor
import akka.actor.UntypedActorContext
import akka.actor.ActorPath
import scala.concurrent.duration.Duration
import java.util.HashMap
import akka.actor.ActorSystem
@aras-p
aras-p / preprocessor_fun.h
Last active April 28, 2024 15:25
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@phatak-dev
phatak-dev / README.md
Last active July 2, 2021 05:03
Functional Programming in C++

#Compilng You need g++ 4.9 to compile this code. Follow these steps to install g++-4.9

After installing run the following command to compile

/usr/bin/g++-4.9 -std=c++11 lambda.cpp

#Running

./a.out
@Measter
Measter / brainfuck.x86
Last active August 29, 2015 14:23
Brainfuck Assembler
*-----------------------------------------------------------
* Title : Brainfuck Assembler
* Written by : Stuart Haidon
* Date : 2015-06-16
* Versions:
* 1.0: Release
* 1.1: Changed JMP instruction in assembled program to RTS.
* 1.2: Now handles mis-matched brackets.
*-----------------------------------------------------------
@bcardiff
bcardiff / for.cr
Last active September 5, 2019 18:09
for crystal
macro for(expr)
{{raise "invalid syntax. use for e in c." unless expr.args.first.name.stringify == "in"}}
{{expr.args.first.args.first}}.each do |{{expr.name.id}}|
{{expr.args.first.block.body}}
end
end
for e in 1..5 do
puts e
end
@mame
mame / main.rb
Created November 8, 2015 14:07
eval$x=%q(eval(%w(s="]k<<k7@k9
9k@,7&]-7k.@61y?c<c@9k.?isu:,e
y<?2k_i]61 o@3i>k@_]9_g36o1@
i4k?w/r?1o ?i=i?yoy65kok95
qw6?ci_:<ye g'=ok?;g'n/g?o
i2?.(]{8{)- u8c@4>]u8c-u@
gq7?@4]0;g? ;|g|;]*qkbk0e
g,_@eqqeqqg @>'] a<<0e4e5
oi{25>|>?@ c8 &7*3986
@a;;0+>*@2 _i m{@{+_(
@graphitemaster
graphitemaster / WORKING_AROUND_OFFSETOF_LIMITATIONS.MD
Last active February 29, 2024 08:49
Working around offsetof limitations in C++

Working around offsetof limitations in C++:

There is sometimes a situation in which one needs to get the relative offset of a structure field, common examples of this include serialization frameworks which aid to serialize objects, vertex attributes for rendering (D3D, GL.), etc.

The most common technique for getting this information is through the offsetof macro defined in stddef.h. Unfortunately using the macro in C++ comes with a new set of restrictions that prevent some (subjectively valid) uses of it.