Skip to content

Instantly share code, notes, and snippets.

type Foo = distinct int
template `&`(a: Foo, b: Foo): expr =
debugEcho "anding"
const x = a
Foo(int(a) + int(b))
echo int(Foo(1) & Foo(2) & Foo(3) & Foo(4) & Foo(5))
@judofyr
judofyr / a.md
Created April 22, 2014 11:47
Patch for Ruby 2.1.1
ruby-install -p https://gist.githubusercontent.com/judofyr/11175629/raw/2f22144e3ca261e9e989fcb9a205b473c208007f/patch.diff ruby 2.1.1
def extract_session
envs = ObjectSpace.each_object(Hash).lazy.select { |env| env.key?("rack.version") && env.key?("rack.session") }
before = envs.to_a
GC.disable
yield
after = (envs.to_a - before)
raise "Could not extract session" unless after.size == 1
after.first['rack.session']
ensure
GC.enable
@judofyr
judofyr / lazy.scm
Created July 29, 2013 15:02
Lazy lists without closures in Scheme
#lang r5rs
; A lazy list is a cons of two values: a head (a value) and a tail,
; a lambda that returns other lazy list. It's very easy to create a
; closure-based implementation:
(define (lazy-from n)
(cons n (lambda () (lazy-from (+ 1 n)))))
(define (lazy-head lst) (car lst))
(define (lazy-tail lst) ((cdr lst)))
From 714fc294b5ade1f502c45fabab573630f09a0889 Mon Sep 17 00:00:00 2001
From: Magnus Holm <[email protected]>
Date: Mon, 6 May 2013 22:27:03 +0200
Subject: [PATCH] Fix stupid bug
---
lib/bundler/resolver.rb | 47 ++++++++-----------------------------------
spec/resolver/basic_spec.rb | 22 ++++++++++++++++++++
2 files changed, 30 insertions(+), 39 deletions(-)
@judofyr
judofyr / age.py
Last active December 16, 2015 11:28
Secret Secure Relative Age Service
# paillier.py and primes.py attached below are verbatim from
# https://github.com/mikeivanov/paillier
#
# This code is licenced under # LGPL v3.
#
# Usage
# Person 1: python age.py MY_AGE
# Person 2: python age.py MY_AGE OUTPUT_FROM_PERSON1
#
# Person 2 should then post the output here and I can publicize the relative age.
@judofyr
judofyr / foo.html
Last active December 14, 2015 04:39
formproxy
<script>parent.postMessage("Hello world", "*")</script>
#!/usr/bin/env ruby
#
# Proof-of-Concept RCE exploit against Gemcutter
#
# ## Advisory
#
# ## Caveats
#
# ## Synopsis
#
@judofyr
judofyr / svg.css
Created November 2, 2012 13:13
Sass-mixin for SVG + PNG-fallback
.lt-ie9 .error {
background-image: url("images/sprites/sprite.png"); }
.error {
background-image: url("images/sprites/sprite.svg"); }
@judofyr
judofyr / gist:3833966
Created October 4, 2012 14:42
Issues with NPM's conceptual model

Let's say someone has implemented a module for sets that's being used in two modules.

a.js:

var set = require("set");

export.thing = set(1, 2, 3);