Skip to content

Instantly share code, notes, and snippets.

View scottbaggett's full-sized avatar
:electron:

Scott scottbaggett

:electron:
View GitHub Profile
Template.articlesForm.events
'submit #formNewArticle': (e, tmpl) ->
e.preventDefault()
# article properties
article =
created_at: new Date()
published_on: new Date(tmpl.find(".datepicker").value)
title: tmpl.find('#inputTitle').value
@scottbaggett
scottbaggett / gist:5384065
Created April 14, 2013 20:23
death of the hashbang
# First, we should prevent the Hashbang from ever occuring by
# overriding Backbone’s ‘loadUrl’ method (Hat tip to Michael Franzkowiak):
Backbone.History.prototype.loadUrl = (fragmentOverride) ->
fragment = this.fragment = this.getFragment(fragmentOverride,
this._wantsPushState &&
!this._wantsHashChange)
matched = _.any this.handlers, (handler) ->
if handler.route.test(fragment)
handler.callback(fragment)
@scottbaggett
scottbaggett / gist:4989064
Created February 19, 2013 19:32
api call
create_invite: (entity_id, callback=->) =>
$.ajax
type: "PUT"
url: "#{@address}/invites/entities/#{entity_id}"
success: callback
error: (event) ->
log "LOG:","createinvite_error", event
@scottbaggett
scottbaggett / gist:4559573
Last active December 11, 2015 06:28
sublime text preferences
{
"color_scheme": "Packages/User/Espresso Soda.tmTheme",
"detect_indentation": true,
"file_exclude_patterns":
[
".scss",
".DS_Store",
".sassc",
".scssc",
"*.css.sassc",
# db/migrations/20120118012543_create_site_configuration.rb
class CreateSiteConfigurations < ActiveRecord::Migration
def change
create_table :site_configurations do |t|
t.string :key
t.text :value
t.string :form_type
t.string :form_collection_command
@scottbaggett
scottbaggett / gist:3949763
Created October 25, 2012 00:16
center items inside edge animation
// Add the 'center' class to any element you want to center on resize.
// Using this in combination with the scale-background mode will make backgrounds
// work on all sizes, Yay!
var $center_items = $(".center");
var center;
window.resize = function() {
console.log("resize");
$center_items.each(function(i,el){
@scottbaggett
scottbaggett / gist:3802547
Created September 28, 2012 23:10
running rake tasks from inside another rake task
task :build_all do
[ :debug, :release ].each do |t|
$build_type = t
Rake::Task["build"].reenable
Rake::Task["build"].invoke
end
end
@scottbaggett
scottbaggett / deployer.rake
Created September 28, 2012 23:03
Rake task to copy local files to remote server via FTP
# Rake task to copy local files to remote server via FTP
# required credentials.yml file, that contains keys:
# server, username, password
require "net/ftp"
require "yaml"
class FTPClient
attr_reader :remote_path
Never hardcode sensitive information (account credentials, passwords, etc.) into your code. Instead, create a file to store that information as environment variables (key/value pairs), and exclude the file from your source code management system. For example, in terms of Git, .gitignore that file:
-bash> echo "config/app_environment_variables.rb" >> .gitignore
config/app_environment_variables.rb
ENV['HTTP_USER'] = 'devuser'
ENV['HTTP_PASS'] = 'devpass'
As well, add the following lines to config/environment.rb, between the require line, and the Application.initialize line:
# Load the app's custom environment variables here, so that they are loaded before environments/*.rb
@scottbaggett
scottbaggett / gist:3769086
Created September 23, 2012 06:29
jQuery column manager
jQuery(document).ready(function($) {
var CollManag = (function() {
var $ctCollContainer = $('#ct-coll-container'),
collCnt = 1,
init = function() {
changeColCnt();
initEvents();
initPlugins();
},
changeColCnt = function() {