Skip to content

Instantly share code, notes, and snippets.

class Rating < ActiveRecord::Base
belongs_to :thing, :polymorphic => true
end
class Comment < ActiveRecord::Base
has_many :ratings
end
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
-module(shop).
-author('Eduard Bondarenko <edbond@gmail.com>').
-compile(export_all).
main(_) ->
io:format("Welcome to shop you need.").
### getargs demo
#include <unistd.h>
#include <stdio.h>
int main (int argc, char *argv[])
{
int ch;
int avgSec = 0;
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
// 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
//
#!/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
#!/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')
SELECT COUNT(*)
FROM R
WHERE NOT EXISTS (SELECT 1
FROM S
WHERE S.A = R.A)
"
" 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;