Skip to content

Instantly share code, notes, and snippets.

View pczarn's full-sized avatar
🇵🇱
Proland

Peter Blackson pczarn

🇵🇱
Proland
  • Poland
  • 08:55 (UTC +02:00)
View GitHub Profile
@ammar
ammar / ruby_wrappers.c
Created May 25, 2012 10:23
Examples of wrapping rb_funcall and rb_funcall2 with rb_rescue2.
#define MY_FUNCALL_ARGC 3
VALUE my_funcall(VALUE receiver, ID method_id, int argc, ...);
VALUE my_funcall_ex(VALUE data);
VALUE my_funcall2(VALUE receiver, ID method_id, int argc, VALUE *argv);
VALUE my_funcall2_ex(VALUE data);
// my_rescue: exception handler used by both of the wrappers below.
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active July 31, 2024 13:08
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@andkerosine
andkerosine / raskell.rb
Created August 15, 2012 05:56
Haskell-like list comprehensions in Ruby
$stack, $draws = [], {}
def method_missing *args
return if args[0][/^to_/]
$stack << args.map { |a| a or $stack.pop }
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :<
end
class Array
def +@
@sindresorhus
sindresorhus / git-dirty-checks.md
Created October 16, 2012 11:20
Benchmark results of the fastest way to check if a git branch is dirty

Tested against the WebKit git repo by entering the repo with 1 file dirty.


git diff --quiet --ignore-submodules HEAD # Will tell if there are any uncomitted changes, staged or not.
0.6 sec

git diff-index --quiet HEAD # Only tracked
2 sec

anonymous
anonymous / gist:4591596
Created January 22, 2013 02:34
require 'llvm/core'
require 'llvm/execution_engine'
require 'llvm/transforms/scalar'
class Generator
attr_accessor :ptr
def build(code,name, mod)
@mashiro
mashiro / message.hpp
Last active June 15, 2023 09:54
zeromq + msgpack
#include <string>
#include <ctime>
#include <msgpack.hpp>
struct message
{
std::string tag;
std::time_t time;
std::string text;
MSGPACK_DEFINE(tag, time, text);
@ssylvan
ssylvan / rh_hash_table.hpp
Last active January 12, 2023 04:52
Quick'n'dirty Robin Hood hash table implementation. Note, I have implemented this algorithm before, with tons of tests etc. But *this* code was written specifically for the blog post at http://sebastiansylvan.com/post/robin-hood-hashing-should-be-your-default-hash-table-implementation/, it has not been extensively tested so there may be bugs (an…
#define USE_ROBIN_HOOD_HASH 1
#define USE_SEPARATE_HASH_ARRAY 1
template<class Key, class Value>
class hash_table
{
static const int INITIAL_SIZE = 256;
static const int LOAD_FACTOR_PERCENT = 90;
struct elem
@mstewartgallus
mstewartgallus / gadts.rs
Last active November 2, 2019 18:59
Gadts in Rust
/// This type is only every inhabited when S is nominally equivalent to T
pub type Is <S, T> = Is_ <S, T>;
priv struct Is_ <S, T>;
// Construct a proof of the fact that a type is nominally equivalent
// to itself.
pub fn Is <T> () -> Is <T, T> { Is_ }
pub impl <S, T> Is_ <S, T> {
@wolever
wolever / profile
Created September 11, 2013 15:41
My very fast Bash prompt, which shows git branch, virtualenv, and background jobs
# prompt examples:
# [3 jobs master virtualenv] ~/code/myproject/foo
# [1 job my-branch virtualenv] ~/code/bar/
# [virtualenv] ~/code/
# ~
# Very, very fast, only requiring a couple of fork()s (and no forking at all to determine the current git branch)
if [[ "$USER" == "root" ]]
then
export PS1="\e[1;31m\]\u \[\e[1;33m\]\w\[\e[0m\] ";
@hofmannsven
hofmannsven / README.md
Last active July 16, 2024 01:30
Git CLI Cheatsheet