Skip to content

Instantly share code, notes, and snippets.

🎣
gone fishing

Evadne Wu evadne

🎣
gone fishing
Block or report user

Report or block evadne

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@evadne
evadne / script.sh
Created Apr 28, 2019
Properly invoke Sublime Text from WSL
View script.sh
function subl () {
SublimePath="/mnt/c/Program Files/Sublime Text 3/subl.exe"
TargetPath=$(readlink -f $1)
HomePath="/home/evadne"
ProjectsPath=$(readlink -f $HomePath/projects)
SublimeProjectsPath=$(readlink -f $HomePath/sublime)
echo "Editing $TargetPath"
case $TargetPath/ in
$ProjectsPath/*)
View .gitignore
out.txt
out-sorted.txt
words.txt
@evadne
evadne / 01-multistage-build.sh
Last active Feb 6, 2019
Build & Cache multi-stage Docker images (with Build Specification for AWS CodeBuild)
View 01-multistage-build.sh
# the general idea
ImageTag="git"
FilePath="/Dockerfile"
RepoURI="123456789012.dkr.ecr.eu-west-1.amazonaws.com/repo"
Stages=$(cat $FilePath | grep -oP '^FROM .+ (AS|as) \K(.+)$')
CacheArgs=$(for Stage in $Stages; do echo "--cache-from $RepoURI:cache-$Stage"; done | paste -sd ' ')
BuildArgs="--file $FilePath $CacheArgs"
for Stage in $Stages; do docker pull $RepoURI:cache-$Stage || true; done
for Stage in $Stages; do docker build $BuildArgs --tag $RepoURI:cache-$Stage --target $Stage . || break; done
docker build $BuildArgs --tag $RepoURI:$ImageTag .
@evadne
evadne / gist:440558b18228ca657ef22b465793a0c3
Last active Nov 27, 2018
Using SchemaCrawler on PostgreSQL databases
View gist:440558b18228ca657ef22b465793a0c3
@evadne
evadne / srcds_rcon.ex
Created Nov 12, 2018
Source RCON client in Elixir (using gen_tcp)
View srcds_rcon.ex
defmodule HuddleGateway.External.SourceRemoteControl do
@moduledoc """
A simple gen_tcp based implementation of a Source RCON client
- [Source RCON Protocol](https://developer.valvesoftware.com/wiki/Source_RCON_Protocol)
By calling `connect/2`, you can obtain an open TCP socket,
which can then be used with `auth/3` or `exec/3`.
"""
@evadne
evadne / environment.ex
Created Nov 11, 2018
Environment Variable based Config Provider
View environment.ex
defmodule Huddle.Environment do
use GenServer
@config_entries [
{:huddle_web, HuddleWeb.Endpoint, ~w(http port)a, {:system, "PORT"}}
]
def start_link(args) do
GenServer.start_link(__MODULE__, args)
end
@evadne
evadne / xmastree.ex
Last active Aug 29, 2018
Christmas Trees in Elixir
View xmastree.ex
defmodule Tree do
def print(n) do
for i <- 1 .. n do
p(n - i, " ")
p(i * 2 - 1, "*")
w("\n")
end
p(n - 1, " ")
w("|\n")
end
View cfn-region-mapping.sh
#!/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="[
View ex_aws_s3_sign.ex
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 / a-reverse-bench.exs
Last active Jul 16, 2019
Reversing Binaries in Elixir
View a-reverse-bench.exs
defmodule Benchmarker do
def run(title, module, function, size \\ 1024, iterations \\ 100) do
times = for (_ <- 1 .. iterations) do
data = :crypto.strong_rand_bytes(size)
{duration, _value} = :timer.tc fn ->
apply(module, function, [data])
end
duration
end
You can’t perform that action at this time.