Skip to content

Instantly share code, notes, and snippets.

View augustl's full-sized avatar

August Lilleaas augustl

  • Oslo, Norway
View GitHub Profile
;; UTF-8
(require 'un-define "un-define" t)
(set-buffer-file-coding-system 'utf-8 'utf-8-unix)
(set-default buffer-file-coding-system 'utf-8-unix)
(set-default-coding-systems 'utf-8-unix)
(prefer-coding-system 'utf-8-unix)
(set-default default-buffer-file-coding-system 'utf-8-unix)
@augustl
augustl / application_helper.rb
Created October 29, 2008 14:24
The simplest thing that could possibly work.
def path_to_attachment_image(attachment)
image_path("attachments/#{attachment.filename}")
end
@augustl
augustl / conditions.rb
Created November 10, 2008 08:15
Experimental finder syntax thingie, lol.
require 'rubygems'
require 'active_support'
# Turns
# c('title LIKE ', "%#{query}%", ' AND published = ', true)
# into
# ['title LIKE ? AND published = ?', "%#{query}%", true]
#
# In other words, ladies and mentlegen, you can now do a find as such:
# find(:all, :conditions => c('gender =', params[:gender], 'AND published =', true))
pun = Httpun.get('http://google.com/')
case pun.status
when 400..403
# uh.. yeah
when 404
# indeed
else
# yep
end
// 'mySlideshow' will always have the size of the movie clip. Even if it's being resized in a browser window (thanks to the scaleMode)
stage.align = StageAlign.TOP_LEFT
stage.scaleMode = StageScaleMode.NO_SCALE
var resizeHandler = function(e){
var stageWidth:Number = Math.round(mySlideshow.stage.stageWidth)
var stageHeight:Number = Math.round(mySlideshow.stage.stageHeight)
mySlideshow.width = stageWidth;
mySlideshow.height = stageHeight;
(function($){
function Calendar(dayRenderFunc, options){
this.dayRenderFunc = dayRenderFunc
this.settings = $.extend({
month: new Date(),
firstDayOfWeek: 0,
tableAttributes: {
"class": 'calendar'
}
}, options)
(function($){
$.fn.inlineLabels = function(options){
var self = this; // scope..
this.labelElements = this.find("input:text, textarea")
var settings = $.extend({
suffix: '...'
}, options)
this.labelElements.each(function(i, input){
// Twitter Hashtag Ignore
// version 0.3
// 2008-01-25
// Copyright (c) 2009, August Lilleaas
// Released under the MIT license
// http://www.opensource.org/licenses/mit-license.php
//
// ==UserScript==
// @name Twitter Hashtag Ignore
// @namespace http://www.twitter.com/*
@augustl
augustl / stuff.rb
Created January 29, 2009 12:17
Handling extensions to built-in classes
# Include all the files in lib/core_ext
Dir.glob(File.join(Rails.root, 'lib', 'core_ext', '*.rb')).each do |core_ext|
require core_ext
end
@augustl
augustl / app_template.rb
Created February 10, 2009 22:29
Rails 2.3 app template
# Remove some files we don't need.
%w(public/javascripts/* public/index.html public/images/rails.png).each do |path_spec|
run "rm #{path_spec}"
end
# jQuery!
run "curl http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js > public/javascripts/jquery.js"
file "public/javascripts/application.js"
# Create app/views/layouts/application.html.erb