Skip to content

Instantly share code, notes, and snippets.

View evadne's full-sized avatar
🎣
gone fishing

Evadne Wu evadne

🎣
gone fishing
View GitHub Profile
@evadne
evadne / gist:8424f4dee3243e96e35ec5b6ecc8568f
Created June 29, 2017 19:13
Erlang/OTP 20, wxmac 3.1.0, macOS 10.13 17A291m
Overlord:~ evadne$ brew install erlang
==> Installing dependencies for erlang: autoconf, automake, libtool, pkg-config, makedepend, openssl, jpeg, libpng, libtiff, wxmac
==> Installing erlang dependency: autoconf
==> Using the sandbox
==> Downloading https://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/autoconf/2.69 --with-lispdir=/usr/local/Cellar/autoconf/2.69/share/emacs/site-lisp/autoconf
==> make install
==> Caveats
Emacs Lisp files have been installed to:
@evadne
evadne / main.exs
Last active June 25, 2017 22:35
Cosine Similarity with Elixir
defmodule Script do
def cosine_similarity(lhs, rhs) do
{ab, aa, bb} = accumulate(lhs, rhs)
ab / (:math.sqrt(aa) * :math.sqrt(bb))
end
defp accumulate(lhs, rhs) do
accumulate(lhs, rhs, 0, 0, 0)
end
macOS 10.12.1 (Build 16B2659)
https://browser.geekbench.com/v4/compute/295179
https://browser.geekbench.com/v4/compute/295180
https://browser.geekbench.com/v4/compute/295182
https://browser.geekbench.com/v4/compute/295185
https://browser.geekbench.com/v4/compute/295187
macOS 10.12.2 (Build 16C63a)
https://browser.geekbench.com/v4/compute/295151
https://browser.geekbench.com/v4/compute/295161
@evadne
evadne / 0_CONTRIBUTORS.md
Last active July 14, 2023 12:52
RVM + MRI + Capistrano + Puma + Sidekiq
  • Josh Goebel (@yyyc514): suggested lazy evaluation on set
@evadne
evadne / ephemeral_token.rb
Created July 23, 2015 07:51
Ephemeral Secure Token with JWT
class EphemeralToken
attr_reader :origin, :targets, :expires_at, :payload
class TokenInvalid < StandardError; end
class TokenExpired < TokenInvalid; end
Algorithm = 'HS512'
Secret = ENV['SECRET_EPHEMERAL_TOKEN_KEY']
ObjectToNotation = -> (target) { [target.class.model_name.name, target.id] }
NotationToObject = -> ((model_name, model_id)) { model_name.constantize.find_by_id(model_id) }
@evadne
evadne / journal
Last active August 29, 2015 14:07
$ fleetctl journal -f [email protected]
core@deis-1 ~ $ fleetctl journal -f [email protected]
-- Logs begin at Wed 2014-10-08 14:11:41 UTC. --
Oct 10 15:03:08 deis-3 sh[30201]: [50cca74e] -job image_get(2f651070bd84650340ba1210ef10a8957c74c9dc32d39ff3bf4625cbc355ca1b) = ERR (1)
Oct 10 15:03:08 deis-3 sh[30201]: [50cca74e] +job image_get(fb8e2f5f8a6c25dcafe9d8a79ca35471a3a4251690581756fdad117046b199a4)
Oct 10 15:03:08 deis-3 sh[30201]: No such id: fb8e2f5f8a6c25dcafe9d8a79ca35471a3a4251690581756fdad117046b199a4
Oct 10 15:03:08 deis-3 sh[30201]: [50cca74e] -job image_get(fb8e2f5f8a6c25dcafe9d8a79ca35471a3a4251690581756fdad117046b199a4) = ERR (1)
Oct 10 15:03:08 deis-3 sh[30201]: [50cca74e] +job image_get(4fc3518d6f3593906bb563241420abc018cfbfd705fe6528d3b22580bc625a49)
Oct 10 15:03:08 deis-3 sh[30201]: No such id: 4fc3518d6f3593906bb563241420abc018cfbfd705fe6528d3b22580bc625a49
Oct 10 15:03:08 deis-3 sh[30201]: [50cca74e] -job image_get(4fc3518d6f3593906bb563241420abc018cfbfd705fe6528d3b22580bc625a49) = ERR (1)
Oct 10 15:03:08 deis-3 sh[30201]:
@evadne
evadne / sidekiq.rb
Created April 28, 2014 04:03
Starter Sidekiq Configuration
# config/initializers/sidekiq.rb
require 'sidekiq'
Sidekiq.configure_client do |config|
config.redis = {
:url => ENV['SIDEKIQ_REDIS_URI'],
:namespace => ENV['SIDEKIQ_NAMESPACE'],
:size => ENV['SIDEKIQ_CLIENT_SIZE'] || 5
}
@evadne
evadne / RAEditorView.m
Created January 6, 2014 19:47
Hide UIWebView Keyboard Bar
@implementation RAEditorView
- (instancetype) initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
[self setup];
}
return self;
}
@evadne
evadne / hax.js
Created July 15, 2013 01:21
Semicolon Jeopardy
var something = function () {
alert("something destructive.");
}
((function(){
alert("do it now. :D");
})());
// Function declaration for `something` is underhanded.
// It has no terminating semicolon, so the immediately evaluated expression,
@evadne
evadne / gist:5794585
Last active April 18, 2023 18:01
WWDC 2013 Videos / Slides (PDF) Downloader — run in a JavaScript console / interpreter hooked to the videos page
// Download all assets from https://developer.apple.com/wwdc/videos
// Warning: might take up a lot of disk space
NodeList.prototype.toArray = function () {
return Array.prototype.slice.call(this);
};
[].concat.apply([], document.querySelectorAll("li.session").toArray().map(function(session){
var sessionID = session.id.match(/^\d+/)[0];
var title = session.querySelector(".title").innerText;