Skip to content

Instantly share code, notes, and snippets.

View gist:46570
# This is a blog post I wrote almost two years ago. It was some of the first Ruby I ever uttered, and not
# entirely useful or elegant, but I'm reposting it now because I recently received a requst for it.
# Ruby on Rails: Working With a Legacy Database With a Non-Integer Primary Key
# For a project I'm currently working on, I needed to get my Rails application to work with a legacy
# database that used a non-integer primary key (in this case, a field called "loginID", which is basically
# a username). First, I tried to use "set_primary_key" to define my PK, but Rails was having none of that.
@joeyschoblaska
joeyschoblaska / chess_fen.py
Created Mar 11, 2012
Chess FEN plugin for Anki, modified to display the board from black's perspective if it is his turn to move: http://uucode.com/blog/2011/06/27/chess-fen-plugin-for-anki/
View chess_fen.py
# chess fen
# Anki plugin to generate chess diagramms
# ===========================================================
#
# The plugin converts "fen" tag to a corresponding image.
#
# The original text:
#
# :: Do you like this position?
# :: [fen]rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1[/fen]
View gist:2080024
<?xml version="1.0" standalone="no"?>
<svg viewBox = "0 0 1100 350" version = "1.1" preserveAspectRatio = "xMidYMid meet" zoomAndPan = "magnify" contentScriptType = "application/ecmascript" contentStyleType = "text/css">
<circle cx="400" cy="350" r="300" stroke="red" stroke-width="5" fill="none"/>
<circle cx="100" cy="50" r="3" stroke="blue"fill="blue"/>
<path id = "quadcurveABC" d = "M 100 350 q 0 -300 300 -300" stroke = "blue" stroke-width = "5" fill = "none"/>
</svg>
View gist:3171990
diff --git a/spec/urbanairship_spec.rb b/spec/urbanairship_spec.rb
index 224591e..2fa550f 100644
--- a/spec/urbanairship_spec.rb
+++ b/spec/urbanairship_spec.rb
@@ -454,9 +454,12 @@ describe Urbanairship do
end
it "does not attempt to log if logger is not set" do
+ Urbanairship::Timer.should_receive(:timeout).with(5.0).and_raise(Timeout::Error)
Urbanairship.logger = nil
@joeyschoblaska
joeyschoblaska / text_cats
Last active Mar 7, 2017
An example of the "text/cats" content-type.
View text_cats
$ curl -v "http://api.groupon.com/v2/deals/nori-chicago-2.cats?client_id=21a3dda11309f0db69bdbefddda4a9625a66cd77"
< HTTP/1.1 200 OK
< Content-Type: text/cats; charset=utf-8
{"de
al":{"
tipped
At":"2
@joeyschoblaska
joeyschoblaska / craigslist.rake
Last active Dec 16, 2015
A rake task to scan Craigslist periodically and email any new listings that match a set of parameters.
View craigslist.rake
require 'open-uri'
def in_bounds?(lat, lng)
bounds = [
{:north => 41.87849, :east => -87.623917, :south => 41.872041, :west => -87.633787}
]
bounds.any?{|b| lat >= b[:south] && lat <= b[:north] && lng <= b[:east] && lng >= b[:west]}
end
View doge
# ami-9f6150f6 and g2.2xlarge =~ 145 doge/hour
# request spot instances at a max price
vim cudaminer.json
vim cpuminer.json
sudo restart cudaminer
sudo restart cpuminer
sudo tail -f /var/log/upstart/cudaminer.log /var/log/upstart/cpuminer.log
View keybase.md

Keybase proof

I hereby claim:

  • I am joeyschoblaska on github.
  • I am joeyschoblaska (https://keybase.io/joeyschoblaska) on keybase.
  • I have a public key whose fingerprint is A2BA 9022 9DA2 1357 CFBD 915F 2053 C1F0 2BA0 C961

To claim this, I am signing this object:

View gist:636eef7c9f85f1c68425
AMERICAN
4 Hands slngle speed
4 H£Dl1.S'E!SWlD_l] Ca, 5L Llmls, M0
541; MW
Allagash whlte
Allagasa Ersmng company, ponlanlz ME
5241: MW
View gist:98feb746dc49c01dcc04

start with an opening explorer. have a way to comment on each position, maybe even to up/downvote comments so that a user can give a good explanation of what is going on in the position and have it surface to the top. solicit comments for each move and position, prioritizing the most common-occuring ones. good, approachable explanations like this: http://www.eudesign.com/chessops/epin-01b.htm

let players upload their games. analyze them, show blunders, rating changes. nice commenting system to make analysis easier. take tactics from games and put them into a tactics trainer pool. use this to figure out how difficult each tactic is and to get users to classify them. use this info to help players understand what tactics they're missing in their games. automatically build their opening book based on what they play, and help them find holes

when using opening explorer, allow user to choose different game sets. ex: I want to know what people rated 1200-1400 play against this defense

take the chess position trai