This file contains 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
# Builds an SQL insert query for a given record | |
# | |
# @param record [ActiveRecord::Base] Record used to build the SQL insert query | |
# @return [String] SQL insert query | |
def build_insert_query(record) | |
columns = record.class.columns.reject { |col| col.name == record.class.primary_key } | |
values = columns.map { |col| record[col.name] } | |
insert_manager = Arel::InsertManager.new | |
insert_manager.into(record.class.arel_table) | |
insert_manager.insert(columns.zip(values)).to_sql |
This file contains 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
[ | |
{ | |
"name": "Afghanistan", | |
"dial_code": "+93", | |
"code": "AF" | |
}, | |
{ | |
"name": "Aland Islands", | |
"dial_code": "+358", | |
"code": "AX" |
This file contains 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
<?php | |
class Banxico | |
{ | |
const banxicourl = 'http://www.banxico.org.mx:80/DgieWSWeb/DgieWS?WSDL'; | |
private $_client; | |
private $_debug = false; | |
public function getExRate() | |
{ |
This file contains 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
# The command finds the most recent tag that is reachable from a commit. | |
# If the tag points to the commit, then only the tag is shown. | |
# Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object | |
# and the abbreviated object name of the most recent commit. | |
git describe | |
# With --abbrev set to 0, the command can be used to find the closest tagname without any suffix: | |
git describe --abbrev=0 | |
# other examples |
This file contains 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
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine | |
# This is how I upload my new Sol Trader builds (http://soltrader.net) | |
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash | |
S3KEY="my aws key" | |
S3SECRET="my aws secret" # pass these in | |
function putS3 | |
{ | |
path=$1 |
This file contains 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/env ruby | |
# Validates that you don't commit forbidden keywords to the repo | |
# You can skip this checking with 'git commit --no-verify' | |
exit 0 if ARGV.include?('--no-verify') | |
# Update this list with your own forbidden keywords | |
KEYWORDS = %w(binding.pry console.log debugger) | |
def red(text) "\033[31m#{text}\033[0m"; end |
This file contains 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
'use strict'; | |
module.exports = function CustomError(message, extra) { | |
Error.captureStackTrace(this, this.constructor); | |
this.name = this.constructor.name; | |
this.message = message; | |
this.extra = extra; | |
}; | |
require('util').inherits(module.exports, Error); |
This file contains 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
wget http://www.currencysymbols.in/flags/afghanistan.png -O AFN.png | |
wget http://www.currencysymbols.in/flags/argentina.png -O ARS.png | |
wget http://www.currencysymbols.in/flags/aruba.png -O AWG.png | |
wget http://www.currencysymbols.in/flags/australia.png -O AUD.png | |
wget http://www.currencysymbols.in/flags/azerbaijan.png -O AZN.png | |
wget http://www.currencysymbols.in/flags/bahamas.png -O BSD.png | |
wget http://www.currencysymbols.in/flags/barbados.png -O BBD.png | |
wget http://www.currencysymbols.in/flags/belarus.png -O BYR.png | |
wget http://www.currencysymbols.in/flags/belize.png -O BZD.png | |
wget http://www.currencysymbols.in/flags/bermuda.png -O BMD.png |
This file contains 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
func timeAgoSinceDate(date:NSDate, numericDates:Bool) -> String { | |
let calendar = NSCalendar.currentCalendar() | |
let unitFlags = NSCalendarUnit.CalendarUnitMinute | NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitDay | NSCalendarUnit.CalendarUnitWeekOfYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitSecond | |
let now = NSDate() | |
let earliest = now.earlierDate(date) | |
let latest = (earliest == now) ? date : now | |
let components:NSDateComponents = calendar.components(unitFlags, fromDate: earliest, toDate: latest, options: nil) | |
if (components.year >= 2) { | |
return "\(components.year) years ago" |
This file contains 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
<form class="form-horizontal" role="form"> | |
<div class="form-group"> | |
<label for="sampleAutocomplete" class="col-sm-3 control-label">Sample Autocomplete</label> | |
<div class="col-sm-9"> | |
<input type="text" class="autocomplete form-control" id="sampleAutocomplete" data-toggle="dropdown" /> | |
<ul class="dropdown-menu" role="menu"> | |
<li><a>Action</a></li> | |
<li><a>Another action</a></li> | |
<li><a>Something else here</a></li> | |
<li><a>Separated link</a></li> |
NewerOlder