Skip to content

Instantly share code, notes, and snippets.

@losvedir
losvedir / twitmail.py
Created September 13, 2010 22:19
Checks a twitter account's most recent tweet. Sends an email if new.
#!/usr/bin/python
import os
import subprocess as sub
import urllib2
from BeautifulSoup import BeautifulSoup
TWITTERUSER = cupcakory # if you want to check twitter.com/cupcakory for updates
EMAILADDR = gabe@example.com
#include <stdio.h>
main() {
int n[] = {1819043144, 663919}, i;
char *c;
c = (char*)n;
printf("%s", c);
@losvedir
losvedir / gist:661564
Created November 3, 2010 19:33
Cracker Barrel Triangle Peg Jumping Game Solver
/* Solves one of those triangle shaped peg jumping puzzles.
You begin with a board composed of n rows, where the i-th
row contains i columns. e.g.:
X
X X
X X X
The board begins with pegs in all holes but one. A peg can
jump over another peg if it can land in a hole on the other
side. The jumped peg is removed. The goal is to finish with
a single peg remaining.
@losvedir
losvedir / Vinegar.txt
Created February 15, 2011 23:18
Breaking Wilhelm von Hackensplat's Vinegar cipher
From HN thread here: http://news.ycombinator.com/item?id=2222228
Challenge posed here: http://blog.hackensplat.com/2011/02/vinegar.html
It seems the cipher is an application of viginere four times. So, if the original
17 character key is x1 x2 y1 y2 y3 z1 z2 z3 z4 z5 t1 t2 t3 t4 t5 t6 t7, and the
original text is C1 C2 C3 C4, then the ciphertext we're given of IWY SEIX....
can be thought of as follows:
I = (C1+x1+y1+z1+t1)
W = (C2+x2+y2+z2+t2)
@losvedir
losvedir / 1 - NEW _delivery.html.erb
Created March 22, 2012 22:13
Convert delivery methods from radio buttons to select options
<%= form.select :shipping_method, shipping_methods_for_select(@order) %>
@losvedir
losvedir / 1 - NEW _delivery.html.erb
Created March 22, 2012 22:16
Convert delivery methods from radio buttons to select options
<%= form.select :shipping_method, shipping_methods_for_select(@order) %>
@losvedir
losvedir / rspec-syntax-cheat-sheet.rb
Created May 11, 2012 15:45 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@losvedir
losvedir / take_that
Created August 22, 2012 21:36
For Stripe CTF
haha
@losvedir
losvedir / Rails SQL stuff
Created December 3, 2012 20:29
Rails 3 ActiveRelation counting, grouping, sorting, and limiting
Model.joins(:relation)
.merge(Relation.scope)
.count(group: 'column or postgres function',
order: 'count_all DESC',
limit: 10
)
# Note: the count_all is the 'AS' variable ActiveRelation makes for you.
class CreateOrganizations < ActiveRecord::Migration
def change
create_table :organizations do |t|
t.string :name
t.boolean :has_octocats
t.timestamps
end
end
end