Skip to content

Instantly share code, notes, and snippets.

Philip Muir philipmuir

  • Sydney
  • 17:17 (UTC +10:00)
View GitHub Profile
@dyrkin
dyrkin / wire_transfer.go
Last active June 28, 2021 13:37
Decomposed WireTransfer FSM definition
func whenInitial(wt *fsm.FSM) fsm.StateFunction {
return func(event *fsm.Event) *fsm.NextState {
transfer, transferOk := event.Message.(*Transfer)
if transferOk && event.Data == nil {
transfer.source <- transfer.amount
return wt.Goto(AwaitFromState).With(
&WireTransferData{transfer.source, transfer.target, transfer.amount, wt},
)
}
return wt.DefaultHandler()(event)
@Petah
Petah / DbMigrate.php
Created July 4, 2016 07:56
Simple Migrate
<?php
namespace MyProject\Cli\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class DbMigrate extends \Symfony\Component\Console\Command\Command
{
@icholy
icholy / gobreak.sh
Last active December 16, 2015 19:18
Shell script to simplify setting GDB breakpoints
# Demo http://ascii.io/a/3019
# build
gdbb () {
# build with debug flags
go build -gcflags "-N -l" -o out
# make sure the build didn't fail
if [ $? != 0 ]; then return; fi
@johntyree
johntyree / getBlockLists.sh
Last active March 9, 2024 12:32
Make one large blocklist from the bluetack lists on iblocklist.com
#!/usr/bin/env sh
# Download lists, unpack and filter, write to stdout
curl -s https://www.iblocklist.com/lists.php \
| sed -n "s/.*value='\(http:.*=bt_.*\)'.*/\1/p" \
| xargs wget -O - \
| gunzip \
| egrep -v '^#'
@cpatni
cpatni / app.rb
Created November 21, 2011 22:39
unique calculation using redis
require 'sinatra'
require 'redis'
require 'json'
require 'date'
class String
def &(str)
result = ''
result.force_encoding("BINARY")
@JonRowe
JonRowe / async_rack_cache.rb
Created December 16, 2010 16:40
Async rack cache monkey patch.... use with caution
require 'async-rack'
require 'rack/cache'
module Rack::Cache
class Context
include AsyncRack::AsyncCallback::Mixin
def async_callback(result)
response = Response.new(*result)
@request ||= Request.new(env.dup.freeze)
store response if response.cacheable?