Skip to content

Instantly share code, notes, and snippets.

Using an assignment expression AND the addition operator, store the SUM of the following three values in a variable:

The number of wheels on a tricycle

The number of calories in Dr. Pepper “Ten”

The number of years depicted in “Seven Years in Tibet”

Additionally, make your variable’s name:

require_dependency 'trusty_cms'
require 'login_system'
class ApplicationController < ActionController::Base
include LoginSystem
protect_from_forgery
before_filter :set_current_user
before_filter :set_timezone
mv /usr/local/bin/g++ /usr/local/bin/g++.bak && ln -s /usr/bin/g++-4.2 /usr/local/bin/g++
rm /usr/local/bin/g++ && mv /usr/local/bin/g++.bak /usr/local/bin/g++
@sipple
sipple / edit_user_controller.js
Last active December 25, 2015 14:38
When I save the model for this controller, I'm trying to use the promise's resolution to transition back from the editUser route to the User route. All of the examples have some version of this.transitionTo (if the action is in the route) or this.transitionToRoute (if in the controller), but no matter where I place the action, the scope of "this…
Seanchai.EditUserController = Ember.ObjectController.extend({
actions: {
cancel: function() {
log.info("cancelling user edit");
this.transitionToRoute('user', this);
},
save: function() {
log.info("submitting user update...");
this.get("model").save().then(function(answer) {
@sipple
sipple / migrate_clipped.rake
Created November 1, 2012 14:21
For those migrating to Radiant CMS 1.0 who used Paperclipped Extension, here's rake task to migrate images from the Paperclipped folder structure to the new Clipped extension folder structure.
require 'fileutils'
namespace :clipped do
desc "Migrate assets from Paperclipped to Clipped"
task :migrate => [:environment] do
skippable_entries = [".", "..", ".DS_Store"]
new_assets_dir = "public/system/assets"
dir = Dir.new("public/assets")
dir.entries.each do |entry|
@sipple
sipple / gist:3939944
Created October 23, 2012 16:35
Time validation
<script type="text/javascript">
jQuery(document).ready(function($){
$('.datepicker').datepicker({ changeMonth: true, changeYear: true, minDate: '-1y', maxDate: '+3y'});
$.validator.addMethod("time", function(value, element) {
return this.optional(element) || /^(([0-1]?[0-9])|([2][0-3])):([0-5]?[0-9])(:([0-5]?[0-9]))?$/i.test(value);
}, "Please enter a valid time.");
$("#post").validate({
rules: {
time: "required time"
@sipple
sipple / about.md
Created August 9, 2011 16:56 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@sipple
sipple / hashthis.js
Created July 11, 2011 15:47
Hash This
function checkCredentials() {
// Set user action to Authenticate
document.UserForm.useraction.value = 'login';
if (document.UserForm.url.value == '') {
alert('Please enter the authenticatin url');
return false;
}
if (document.UserForm.username.value == '' || document.UserForm.password.value == '') {
@sipple
sipple / googlecrap.rb
Created June 21, 2011 18:31
Google Crap
module GoogleCustomSearch
class SearchResultItem
attr_reader :title, :content
def initialize(hash = {})
@errors = []
hash.each do |key, value|
self.instance_variable_set("@#{key}", value)
$(document).ready(function() {
$('td.notes_container input[type="button"]').each(function(index) {
$(this).click(function(event) {
var container = $(this).parent();
ajaxPostNotes(container);
});
});
});