This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'socket' | |
socket = TCPSocket.new('localhost', 7894) | |
socket.puts "'B'*50024" | |
all_data = [] | |
while partial_data = socket.read(2024) | |
puts partial_data | |
puts "-------------------------" | |
all_data << partial_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Today's little useless tidbit converts a url's query string into a hash | |
# set of k/v pairs in a way that merges duplicates and massages empty | |
# querystring values | |
def qs_to_hash(querystring) | |
keyvals = query.split('&').inject({}) do |result, q| | |
k,v = q.split('=') | |
if !v.nil? | |
result.merge({k => v}) | |
elsif !result.key?(k) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Accepts a list and a key function to apply to each item, | |
# and then uses a decorate-sort-undecorate pattern to actually | |
# do the sorting. Returns a new list. Keeps track of the index | |
# to make sure the sort is stable. | |
sort_by = (list, key) -> | |
cmp = ({key: k_a, index: i_a}, {key: k_b, index: i_b}) -> | |
if k_a == k_b then i_a - i_b else if k_a < k_b then -1 else 1 | |
decorated = ({item, index, key: key item} for item, index in list) | |
item for {item} in decorated.sort cmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# active_admin and formtastic seem kinda picky about displaying both the | |
# image and the file input together here... in fact, it seems like this | |
# is the ONLY way to do this? Adding anything else after the image_tag squashes it. | |
ActiveAdmin.register Film do | |
form do |f| | |
f.inputs "Film" do | |
f.input :title | |
end | |
f.has_many :stills do |film_still_form| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source "https://rubygems.org" | |
gem 'puma' | |
gem 'sinatra' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`/** @jsx React.DOM */` | |
converter = new Showdown.converter | |
Comment = React.createClass | |
render: -> | |
rawMarkup = converter.makeHtml @props.children.toString() | |
`<div className="comment"> | |
<h2 className="comment">{this.props.author}</h2> | |
<span dangerouslySetInnerHTML={{__html: rawMarkup}} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Pacific/Kiritimati , cc: KI , offset: 50400 (14 hours) , comments: Line Islands | |
name: Pacific/Chatham , cc: NZ , offset: 49500 (13.75 hours) , comments: Chatham Islands | |
name: Pacific/Fakaofo , cc: TK , offset: 46800 (13 hours) , comments: | |
name: Antarctica/South_Pole , cc: AQ , offset: 46800 (13 hours) , comments: Amundsen-Scott Station, South Pole | |
name: Antarctica/McMurdo , cc: AQ , offset: 46800 (13 hours) , comments: McMurdo Station, Ross Island | |
name: Pacific/Tongatapu , cc: TO , offset: 46800 (13 hours) , comments: | |
name: Pacific/Enderbury , cc: KI , offset: 46800 (13 hours) , comments: Phoenix Islands | |
name: Pacific/Apia , cc: WS , offset: 46800 (13 hours) , comments: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
RSpec.describe TodosController, :type => :controller do | |
describe "GET #index" do | |
#describe "POST #create" do | |
#describe "GET #show" do | |
#describe "PATCH #update" do (or PUT #update) | |
#describe "DELETE #destroy" do | |
#describe "GET #new" do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ $# -ne 1 ]; then | |
echo 'Usage: git-branch-description <branch name>' >&2 | |
exit 1 | |
fi | |
EDITOR='cat' git branch --edit-description "$1" | grep -v '^#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# My First React Component | |
# Added to this Gist for posterity. | |
# Extracted from https://github.com/ministrycentered/transposr/commit/fa616871914ac16b72d0d1b035a08e01e337bd07 | |
# January 08, 2014 | |
{ div, input } = React.DOM | |
AudioFileStepSelector = React.createClass | |
getInitialState: -> | |
halfSteps: 2 |
OlderNewer