Skip to content

Instantly share code, notes, and snippets.

@tdm00
tdm00 / Controller.cfc
Created July 2, 2012 19:55
Restore params after session timeout and re-authentication
<cfcomponent extends="Wheels">
<cffunction name="init">
<cfset filters(through="checkLogin", except="login,authenticate,logout,resetPassword,forgotPassword")>
</cffunction>
<cffunction name="checkLogin">
<cfif StructKeyExists(session, "user")>
<cfset loggedInUser = model("user").findByKey(session.user.id) />
<cfif isDefined("session.gotoredirectparams")>
<!--- make params what the previous ones before timeout --->
@tdm00
tdm00 / gist:3241690
Created August 2, 2012 23:01
ember.js code
diff --git a/js/app.js b/js/app.js
index ff617b3..f6ffa0b 100644
--- a/js/app.js
+++ b/js/app.js
@@ -32,7 +32,7 @@ App.tweetsController = Em.ArrayController.create({
var me = this;
var username = me.get("username");
if ( username ) {
- var url = 'http://api.twitter.com/1/statuses/user_timeline.json'
+ var url = 'http://api.twitter.com/1/statuses/user_timeline.json';
@tdm00
tdm00 / Gemfile
Created August 19, 2012 02:52
Deploy
source 'https://rubygems.org'
gem 'rails', '3.2.8'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development do
gem 'sqlite3'
end
@tdm00
tdm00 / Gemfile.lock
Created August 19, 2012 03:10
Deployment
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.8)
actionpack (= 3.2.8)
mail (~> 2.4.4)
actionpack (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
builder (~> 3.0.0)
@tdm00
tdm00 / locations.cfc
Created August 30, 2012 13:41
Disable debugging output for JSON calls for AJAX
<cfcomponent extends="Controller" output="false">
<cffunction name = "init">
<cfset Super.init() />
</cffunction>
<cffunction name = "remotesearch">
<cfsetting showdebugoutput="false">
<cfset provides("json")>
<cfif IsDefined("params.term") and Len(Trim(params.term)) GT 0>
@tdm00
tdm00 / Preferences.sublime-settings.json
Created September 4, 2012 20:59
Sublime Preferences > Settings - User
{
"color_scheme": "Packages/RailsCasts Colour Scheme/RailsCastsColorScheme.tmTheme",
"fade_fold_buttons": false,
"font_face": "Ubuntu Mono",
"font_size": 18,
"highlight_modified_tabs": true,
"tab_size": 2,
"translate_tabs_to_spaces": true,
"trimTrailingWhiteSpaceOnSave": true
}
# Based on
# http://guides.rubyonrails.org/active_record_querying.html#eager-loading-multiple-associations
# This works
Post.includes(:category, :comments => [:user])
# This does not work
Post.includes(:comments => [:user], :category)
@tdm00
tdm00 / patient.rb
Created October 1, 2012 22:22
Associations to deep?
class Patient < ActiveRecord::Base
# Associations
has_many :Requisitions
# Functions
def full_name
return [given_name, family_name].join(' ')
end
end
@tdm00
tdm00 / Comment.rb
Created October 4, 2012 14:26
Dashboard of posts and comments
class Comment < ActiveRecord::Base
# Associations
belongs_to :post
belongs_to :commenter
end
article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}a:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px;outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}a:hover,a:active{outline:0}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{max-width:100%;width:auto\9;height:auto;vertical-align:middle;border:0;-ms-interpolation-mode:bicubic}#map_canvas img,.google-maps img{max-width:none}button,input,select,textarea{margin:0;font-size:100%;vertical-align:middle}button,input{*overflow:visible;line-height:normal}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:b