Skip to content

Instantly share code, notes, and snippets.

@aaronpowell
aaronpowell / null-guard.sjs
Last active August 29, 2015 13:58
Trying out the C# vNext `?.` operator in Sweet.js
macro null_helper {
rule { ($processed ...) ($rest) } => {
$processed (.) ... . $rest
}
rule { ($processed ...) ($rest_head $rest ...) } => {
$processed (.) ... . $rest_head
&& null_helper ($processed ... $rest_head) ($rest ...)
}
}
@JakeWharton
JakeWharton / GuavaCollectors.java
Last active May 10, 2018 09:08
Example Java 8 collectors for Guava.
/*
* Copyright (C) 2014 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
(import '[javax.script ScriptEngineManager])
(let [engine (.getEngineByName (ScriptEngineManager.) "nashorn")]
(println (= (.eval engine "' \\r\\n' == 0") true)))
@joernchen
joernchen / bounty.txt
Created February 22, 2014 16:17
Bounty writeup
GitHub RCE by Environment variable injection Bug Bounty writeup
Disclaimer: I'll keep this really short but I hope you'll get the key points.
GitHub blogged a while ago about some internal tool called gerve:
https://github.com/blog/530-how-we-made-github-fast
Upon git+sshing to github.com gerve basically looks up your permission
on the repo you want to interact with. Then it bounces you further in
another forced SSH session to the back end where the repo actually is.
@ayosec
ayosec / README.md
Last active August 29, 2015 13:56
Sweet.js: Better for

Add for(value <- items) and for(value, offset <- items) to Sweet.js

Examples

for(x <- [1,2,3,4]) {
  var a = x + 10;
  print(a);
}
@henrik
henrik / ruby_2.1_experiment.rb
Last active January 4, 2016 09:49
Toying with Ruby 2.1 methods returning symbols.
module Wrapping
def wrap(method_name, &block)
# Alternative implementations: either will do the trick.
wrap_with_prepend(method_name, &block)
#wrap_with_bind(method_name, &block)
end
private
def wrap_with_prepend(method_name)
@disnet
disnet / let_async.js
Last active December 31, 2015 04:28
sweet.js: async macro
let let = macro {
rule { async $vars ... = $fname ... ($params ...); $rest ...} => {
$fname ... ($params ..., function (err, $vars ...) {
if (err) throw err;
$rest ...
})
}
}
var buffer = new Buffer(1024);
@windytan
windytan / emoji.pl
Last active August 14, 2023 14:50
Visualize SSH public key fingerprints using Unicode emoji
# Oona Räisänen 2013
# http://windytan.com
# ssh-keygen -l -f ~/.ssh/id_rsa.pub | perl emoji.pl
@emoji = qw( 🌀 🌂 🌅 🌈 🌙 🌞 🌟 🌠 🌰 🌱 🌲 🌳 🌴 🌵 🌷 🌸
🌹 🌺 🌻 🌼 🌽 🌾 🌿 🍀 🍁 🍂 🍃 🍄 🍅 🍆 🍇 🍈
🍉 🍊 🍋 🍌 🍍 🍎 🍏 🍐 🍑 🍒 🍓 🍔 🍕 🍖 🍗 🍘
🍜 🍝 🍞 🍟 🍠 🍡 🍢 🍣 🍤 🍥 🍦 🍧 🍨 🍩 🍪 🍫
🍬 🍭 🍮 🍯 🍰 🍱 🍲 🍳 🍴 🍵 🍶 🍷 🍸 🍹 🍺 🍻
@sgalles
sgalles / i18nUsecase.ceylon
Created November 15, 2013 22:41
Something I've always wanted to do in Java : union of enums. Here, applied to a simple use case : exhaustive (checked by compiler) i18n of an app, with keys coming from different enums.
// enum 1 of application i18n keys
abstract class AppKeyi18n()
of title | description {}
object title extends AppKeyi18n() {}
object description extends AppKeyi18n() {}
// enum 2 of user i18n keys
abstract class UserKeyi18n()
of fieldText1 | fieldText2 | fieldText3 {}
@gbluma
gbluma / exhaustive.rkt
Created September 29, 2013 13:45
Exhaustive pattern matching (refinement types!) in Typed/Racket.
#lang typed/racket
;; We get exhaustive pattern matching
(: f ((U String Integer) -> Boolean))
(define (f x)
(cond
[(string? x) (string=? x "hi")] ; covers string needs
[(exact-nonnegative-integer? x) (= x 7)] ; covers positive integers
[(even? x) (= x -8)] ; we can actually cover a subset of negative integers