This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myCustomConfirmBox = function(message, callback) { | |
var options; | |
options = [ | |
{ | |
'label': 'Yes, Definitely', | |
'class': 'btn-danger', | |
'callback': function() { | |
if (typeof callback === 'function') { | |
return callback(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tastypie.resources import Resource | |
from tastypie import fields | |
class dict2obj(object): | |
""" | |
Convert dictionary to object | |
@source http://stackoverflow.com/a/1305561/383912 | |
""" | |
def __init__(self, d): | |
self.__dict__['d'] = d |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
title: 'Blog Title1', | |
content: 'Body of Blog Post', | |
author: 'User 1' | |
}, | |
{ | |
title: 'Blog Title 2', | |
content: 'Body of Blog Post 2', | |
author: 'User 2' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Handlebars.registerHelper('addition', function(context, options){ | |
return context + parseFloat(options.hash.to); | |
}); | |
/** | |
* usages (handlebars) | |
* {{addition 10 to=10}} | |
* {{addition this to=20}} | |
* {{addition this to="-5"}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Handlebars.registerHelper('short_string', function(context, options){ | |
//console.log(options); | |
var maxLength = options.hash.length || 100; | |
var trailingString = options.hash.trailing || ''; | |
if(context.length > maxLength){ | |
return context.substring(0, maxLength) + trailingString; | |
} | |
return context; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'prime' | |
# This is a quick & simple script to find 333rd of all prime numbers begins & ends with 3. | |
numOfPrime = 0 | |
i = 0 | |
while true do | |
i += 1 | |
if !Prime.prime?(i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rspec' #gem install rspec | |
require './flatten' | |
describe 'myflatten' do | |
it 'makes array single dim regardless of nesting' do | |
expect([1,2,3].myflatten).to eq([1,2,3]) | |
expect([[1,2,3]].myflatten).to eq([1,2,3]) | |
expect([[[1,2,3]]].myflatten).to eq([1,2,3]) | |
expect([[1,2, [3]], [[[[[[[[[4]]]]]]]]], [[5, [6]], 7]].myflatten).to eq([1,2,3,4,5,6,7]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/email_settings.rb | |
ActionMailer::Base.smtp_settings = { | |
user_name: 'SMTP_Injection', | |
password: 'Any API Key with Send via SMTP permission', | |
address: 'smtp.sparkpostmail.com', | |
port: 587, | |
enable_starttls_auto: true, | |
format: :html, | |
from: '[email protected]' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'sparkpost' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
"countryA", | |
"countryB" | |
] |
OlderNewer