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
#!/usr/bin/env bash
export AWS_PROFILE=<snip>
ImageDescription="Amazon Linux AMI 2017.09.1.20180115"
RegionNames=$(aws ec2 describe-regions --region eu-west-1 --query 'Regions[*].[RegionName]' --output text)
function getImages () {
region=$1
filters="[
defp prepare_signed_url({region, bucket, object}, friendly_name) do
config = ExAws.Config.new(:s3, %{region: region})
encoded_name = URI.encode(friendly_name, fn
x when ?0 <= x <= ?9 -> true
x when ?A <= x <= ?Z -> true
x when ?a <= x <= ?z -> true
_ -> false
end)
options = [
@evadne
evadne / wxmac.rb
Created July 14, 2017 02:10
wxmac for Homebrew on macOS 10.13 Beta (17A306f)
class Wxmac < Formula
desc "Cross-platform C++ GUI toolkit (wxWidgets for macOS)"
homepage "https://www.wxwidgets.org"
url "https://github.com/wxWidgets/wxWidgets/releases/download/v3.0.3.1/wxWidgets-3.0.3.1.tar.bz2"
sha256 "3164ad6bc5f61c48d2185b39065ddbe44283eb834a5f62beb13f1d0923e366e4"
head "https://github.com/wxWidgets/wxWidgets.git"
bottle do
cellar :any
sha256 "9766307eb821a254c81002e7318aa89dc2f4cd7a5a09515fce54eb96ae70f898" => :sierra
@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 / .siFancyScrollbar.less
Created February 20, 2010 04:01
Fancy Scrollbar (in WebKit). Written using LESS, needs gem to compile down to regular .CSS.
.siFancyScrollbar {
::-webkit-scrollbar,
::-webkit-scrollbar-button:start:increment,
::-webkit-scrollbar-button:start:decrement,
::-webkit-scrollbar-button:end:increment,
::-webkit-scrollbar-button:end:decrement {
width: 9px;
height: 9px;
@evadne
evadne / gist:5519337
Last active May 17, 2016 09:05
Loading Custom Fonts with CTFontManager
CTFontManagerRegisterFontsForURLs((__bridge CFArrayRef)((^{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *resourceURL = [[NSBundle mainBundle] resourceURL];
NSArray *resourceURLs = [fileManager contentsOfDirectoryAtURL:resourceURL includingPropertiesForKeys:nil options:0 error:nil];
return [resourceURLs filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(NSURL *url, NSDictionary *bindings) {
CFStringRef pathExtension = (__bridge CFStringRef)[url pathExtension];
NSArray *allIdentifiers = (__bridge_transfer NSArray *)UTTypeCreateAllIdentifiersForTag(kUTTagClassFilenameExtension, pathExtension, CFSTR("public.font"));
if (![allIdentifiers count]) {
return NO;
}
@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,