Skip to content

Instantly share code, notes, and snippets.

View amorphid's full-sized avatar

Michael Pope amorphid

  • Digital Turbine
  • San Francisco, CA
View GitHub Profile
@amorphid
amorphid / refinement.rb
Last active September 28, 2018 16:34
Ruby refinement example
#!/usr/bin/env ruby
# here's a good blog post on Refinements => https://blog.codeship.com/ruby-refinements/
# here's some Ruby documentation on Refinements => https://ruby-doc.org/core-2.1.1/doc/syntax/refinements_rdoc.html
class Foo < Struct.new(:bar)
end
module FooTools
refine Foo do
- Determine which environment you'd like to copy
- Fork that environment's repo on Gitlab
- Clone that environment's repo to deploy server
$ deploy_server_ssh ()
{
ssh -A <your username>@sig-swippoc02.internal.synopsys.com
}
$ deploy_server_ssh
$ cd /deploy/repos
@amorphid
amorphid / benchmark.exs
Last active November 8, 2017 01:21
OTP mailbox vs Erlang queue smackdown
#!/usr/bin/env elixir
defmodule MailboxBenchmark do
def start_link(messages) do
count = Enum.at(messages, -1)
pid = spawn_link(fn -> blocked(count) end)
_ = Enum.each(messages, fn (i) -> send(pid, i) end)
{:ok, pid}
end
@amorphid
amorphid / example.cpp
Last active November 2, 2017 21:58
C++ addition precision
#include <iostream>
#include <iomanip>
using namespace std;
int main () {
double a = 0.1;
double b = 0.2;
double result = a + b;
@amorphid
amorphid / osx_ramdisk.sh
Created March 11, 2017 00:00 — forked from jnschulze/osx_ramdisk.sh
Move Chrome, Safari and iTunes Cache to Ramdisk.
#!/bin/bash
# Size at the end is * 2048 where 2048 = 1 MB, so 1572864 = 768 MB
#DISK=`/usr/bin/hdiutil attach -nobrowse -nomount ram://1572864`
DISK=`/usr/bin/hdiutil attach -nobrowse -nomount ram://2097152`
/usr/sbin/diskutil erasevolume HFS+ "RamDiskCache" $DISK
CACHEDIR="/Volumes/RamDiskCache/$USER"
@amorphid
amorphid / 0_reuse_code.js
Created December 15, 2016 22:26
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@amorphid
amorphid / uuid.sh
Created September 15, 2016 00:45
Bash UUID
#!/bin/bash
# Couldn't find a pure Bash utility for UUIDs, so I wrote this for fun (it ain't fast)
base_36_char () {
(
HIGH=${1:-15}
LOW=${2:-0}
RAND_NUM=$RANDOM
@amorphid
amorphid / stack-simple-one-for-one.ex
Created August 12, 2016 06:08 — forked from tastywheat/stack-simple-one-for-one.ex
elixir supervised Stack using simple_one_for_one strategy
# iex(80)> {:ok, _} = Test_1.start_child(:foo)
# {:ok, #PID<0.1214.0>}
# iex(81)> Stack.push(:foo, :hello)
# :ok
# iex(82)> Stack.push(:foo, :hello)
# :ok
# iex(83)> Stack.pop(:foo)
# :hello
# iex(84)> Stack.pop(:foo)
# :hello
@amorphid
amorphid / counter.ex
Last active March 25, 2016 17:50
Elixir counter
defmodule Counter do
use GenServer
# Client
def decrement(pid) do
GenServer.call(pid, :decrement)
end
def count(pid) when is_pid(pid) do
@amorphid
amorphid / computer_science_terms.txt
Last active February 1, 2016 14:48
Computer Science Terms
algotirhm:
- a set of steps (for a computer program) to accomplish a task
data structure:
- a way of organizing data that considers not only the items stored, but also their relationship to each other.