Discover gists
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
class Rating < ActiveRecord::Base | |
belongs_to :thing, :polymorphic => true | |
end | |
class Comment < ActiveRecord::Base | |
has_many :ratings | |
end |
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 'rubygems' | |
require 'rake' | |
require 'rake/gempackagetask' | |
LEGS_GEMSPEC = eval(File.read('mtest.gemspec')) | |
Rake::GemPackageTask.new(LEGS_GEMSPEC) do |pkg| | |
pkg.need_tar_bz2 = true | |
end | |
task :default => "pkg/#{LEGS_GEMSPEC.name}-#{LEGS_GEMSPEC.version}.gem" 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
-module(shop). | |
-author('Eduard Bondarenko <edbond@gmail.com>'). | |
-compile(export_all). | |
main(_) -> | |
io:format("Welcome to shop you need."). |
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
### getargs demo | |
#include <unistd.h> | |
#include <stdio.h> | |
int main (int argc, char *argv[]) | |
{ | |
int ch; | |
int avgSec = 0; |
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
module HasAttributesFor | |
module ActiveRecord | |
def self.included(ar) | |
ar.extend ClassMethods | |
end | |
module ClassMethods | |
def has_attributes_for(association) | |
primary_key_name = reflect_on_association(association).primary_key_name | |
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
// File: | |
// clicks.m | |
// | |
// Compile with: | |
// gcc -o clicks clicks.m -framework ApplicationServices -framework Foundation | |
// | |
// Usage: | |
// ./clicks -x 10 -y 10 (or whatever coordinates you want) | |
// it will click and release, but you can edit the code for the desired effect | |
// |
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/bash | |
# | |
# Converting hex MAC address to decimal? | |
# What, am I crazy or soemthing? | |
echo | |
ifconfig en1 | awk '/ether/ {print $2}' | |
echo | |
for i in {1..6}; | |
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
#!/usr/bin/python | |
# | |
# Sometimes you want to know a little more about your Mac. Maybe this will help. | |
# It's ugly... it's an experiment... | |
import commands | |
import plistlib | |
profileInput = commands.getstatusoutput('system_profiler -xml') |
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
SELECT COUNT(*) | |
FROM R | |
WHERE NOT EXISTS (SELECT 1 | |
FROM S | |
WHERE S.A = R.A) | |
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
" | |
" Find a file. (like cmd-t in textmate) | |
" | |
" Put this into ~/.vim/plugins/Find.vim | |
" | |
" Modified not to find svn files, and not to look in ./vendor | |
" | |
" Based on http://www.vim.org/tips/tip.php?tip_id=1432 by Samuel Hughes | |
" | |
" From his notes; |