Skip to content

Instantly share code, notes, and snippets.

@Phrogz
Phrogz / 01_initial.rb
Created August 31, 2011 18:57
Sequel migration
Sequel.migration do
up do
create_table :customers do
primary_key :id
column :name, :varchar, size:60, null:false
column :organization, :varchar, size:60, null:false
column :email, :varchar, size:60
column :subscribed, :boolean, default:false, null:false
column :extra_str, :varchar, size:60
column :extra_int, :integer
@Phrogz
Phrogz / pry_drb_client.rb
Created September 2, 2011 17:10
Testing Pry with DRb and Threads
SERVER = 'druby://localhost:9123'
require 'drb'
server = DRbObject.new_with_uri(SERVER)
server.go(42)
sleep(0.2)
server.go(17)
server.join_all
@Phrogz
Phrogz / example.rb
Created September 12, 2011 18:29 — forked from AndrewVos/example.rb
example
# Define a method that takes a path to a file and returns an array of all words therein
def read_words( filename )
# Read in the contents of the file and split it into
# an array of strings by finding (and discarding) any "whitespace"
# (spaces, tabs, newlines)
File.read(filename).split(/\s+/)
end
# Define a method that takes an array of words and returns an array without any 'junk' words
def remove_useless_words( all_words )
@Phrogz
Phrogz / gist:1290420
Created October 16, 2011 01:59
Minecraft service for Ubuntu (/etc/init.d/minecraft)
#!/bin/bash
# /etc/init.d/minecraft
# version 0.3.4 2011-06-12 (YYYY-MM-DD)
### BEGIN INIT INFO
# Provides: minecraft
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
@Phrogz
Phrogz / client2.rb
Created October 25, 2011 23:21
One server, multiple clients, asynchronous bi-directional communication using TCP Sockets
#!/usr/bin/env ruby
#encoding: UTF-8
require_relative 'server2'
class Laink::Client
attr_reader :name
def initialize
@server = nil
@name = "Client #{rand(10000).to_s(36)}"
end
@Phrogz
Phrogz / index.html
Created March 19, 2012 16:04 — forked from mbostock/.block
Force-Directed Symbols (D3)
<!DOCTYPE html>
<html>
<head>
<title>Force-Directed Symbols</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.25.0"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js?1.25.0"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?1.25.0"></script>
</head>
<body>
<script type="text/javascript">
@Phrogz
Phrogz / quiz-1.md
Created September 26, 2012 16:31 — forked from ahoward/quiz-1.md
quiz-1.md
So you think you wanna be a web developer...

Fork this, update your copy with answers.

They don't need to be precise - pseudo-code is fine in most cases.

Some questions don't have correct answers.

local lua = [[{
["hello"]="there\nworld",
["array"]={1,2,3,1e6,{["more"]=false},nil,true},
["more"]={
["hello"]="there\nworld",
["array"]={1,2,3,1e6,{["more"]=false},nil,true},
["more"]={
["hello"]="there\nworld",
["array"]={1,2,3,1e6,{["more"]=false},nil,true},
["more"]={
@Phrogz
Phrogz / html5.haml
Last active August 29, 2015 13:56 — forked from fnhipster/html5.haml
!!! 5
%html
%head
%meta(charset="utf-8")
%title Page Title
%meta(name="author" content="")
%meta(name="description" content="")
%meta(name="revisit-after" content="3 days")
%link(href="http://creativecommons.org/licenses/by/4.0/" rel="license" title="Creative Commons Attribution License")
%link(href="/css/screen.css" media="screen" rel="stylesheet")
-------+-------------------------------------------------------------------------------
-- ct | code -------------------------------------------------------------------------
-------+-------------------------------------------------------------------------------
120 local LXSC = require 'lib/lxsc';
*****0 (function(S)
120 S.MAX_ITERATIONS = 1000
120 local OrderedSet,Queue,List = LXSC.OrderedSet, LXSC.Queue, LXSC.List
-- ****************************************************************************