Skip to content

Instantly share code, notes, and snippets.

View augustl's full-sized avatar

August Lilleaas augustl

  • Oslo, Norway
View GitHub Profile
@augustl
augustl / Glavni program
Created July 20, 2008 20:28
Obj-c header file for cocoa app
#include <iostream>
using namespace std;
#include "stog_pokazivaci.h"
//#include "stog_polje.h"
int kraj_rek;
bool print;
module ActiveModel
module Validations
def self.included(base)
base.class_eval do
@validation_stack = {
:any => [],
:create => [],
:update => []
}.freeze
require 'digest/sha1'
class Attachment < ActiveRecord::Base
DIRECTORY = 'attachments'
PATH = File.join(Rails.root, 'public', DIRECTORY)
CHARACTERS = %w(a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9)
validates_presence_of :upload
before_create :set_attributes_from_upload
class Array
def rand
self[Kernel.rand(length)]
end
end
characters = %w(a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9)
Array.new(4).inject("") {|string, ary| string << characters.rand }
def table_listing(collection, &block)
row = RowHandler.new
capture(row, &block)
headers = "<tr>" + row.columns.map {|name, proc| "<th>#{name}</th>" }.join("\n") + "</tr>"
if collection.empty?
rows = "<tr><td colspan=\"#{row.columns.size}\">Ingen treff</td></tr>"
else
rows = collection.map do |item|
output = "<tr>"
(function($){
$.fn.dragscroll = function(target){
// Initializing some locals
var positionWhenScrollStarted
var scrollWhenScrollStarted
var self = this
// The object that is scrolled when this/self is dragged
var targetDOMObject = $(target)
// GitHub Favorites
// version 0.1 (Whiny Whale)
// 2008-09-18
// Copyright (c) 2008, August Lilleaas
// Released under the MIT license
// http://www.opensource.org/licenses/mit-license.php
//
// --------------------------------------------------------------------
//
// This is a Greasemonkey user script. To install it, you need
<html>
<head>
<%= javascript_include_tag *javascripts %>
</head>
<body>
<%= yield %>
</body>
</html>
#!/usr/bin/env ruby
# Runs Rails tests via command line.
#
# * rtest unit - runs all unit tests
# * rtest unit post - runs the unit test for the 'post' model
# * rtest unit post comment foo - runs those tests, yep
# * rtest functional - you guessed it!
# * rtest integration - blows up your computer
# Requires /usr/sbin/sendmail (e.g. postfix)
module Mailer
def self.deliver(to, subject, body)
IO.popen("/usr/sbin/sendmail #{to}", 'w+') do |sendmail|
sendmail.puts "Subject: #{subject}"
sendmail.puts "From: Your Name <[email protected]>"
sendmail.puts "To: #{to}"
sendmail.puts body
end
end