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
Delayed::Worker.max_attempts = 3 | |
Delayed::Backend::Mongoid::Job.send(:include, Delayed::Workless::Scaler) if defined?(Delayed::Backend::Mongoid::Job) |
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 problem was | |
# this file was TAR compressed but not TAR.GZ | |
# | |
uri_path = "http://ftp.ruby-lang.org/pub/ruby/1.9/" + ruby_dir + ".tar.gz" | |
Tempfile.open("ruby-src") { |temp| | |
temp.binmode |
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
var deviceIphone = "iphone"; | |
var deviceIpod = "ipod"; | |
var deviceIpad = "ipad"; | |
var deviceAndroid = "android"; | |
//Initialize our user agent string to lower case. | |
var uagent = navigator.userAgent.toLowerCase(); | |
function detectUserAgent(deviceName) | |
{ |
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
source 'https://rubygems.org' |
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 apn push token you collected from mobile is in this format: | |
# 00ea74e76a873e8e9c14c2dd2afe3b42abb35148e94042811e2b6985072641f2 | |
# | |
# but actually, apn_on_rails is expecting this: | |
# 00ea74e7 6a873e8e 9c14c2dd 2afe3b42 abb35148 e9404281 1e2b6985 072641f2 | |
def format_apn_token(text) | |
text && text.gsub(/(.{8})(?=.)/, '\1 \2') | |
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
# | |
# loading the mechanize library for scraping | |
# install it if you haven't done it: | |
# sudo gem install mechanize | |
# | |
require 'mechanize' | |
agent = Mechanize.new | |
page = agent.get("http://www.openrice.com/english/restaurant/sr2.htm?shopid=32108") |
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
// NOTE: I previously suggested doing this through Grunt, but had plenty of problems with | |
// my set up. Grunt did some weird things with scope, and I ended up using nodemon. This | |
// setup is now using Gulp. It works exactly how I expect it to and is WAY more concise. | |
var gulp = require('gulp'), | |
spawn = require('child_process').spawn, | |
node; | |
/** | |
* $ gulp server | |
* description: launch the server. If there's a server already running, kill it. |
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
.controller('DashCtrl', function($scope, $ionicPlatform, $cordovaGeolocation) { | |
var watch; | |
var watchOptions = { | |
timeout : 5000, | |
maximumAge: 3000, | |
enableHighAccuracy: true // may cause errors if true | |
}; | |
var pollCurrentLocation = function() { | |
$cordovaGeolocation.getCurrentPosition(watchOptions) |
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
require 'rubygems' | |
require 'mechanize' | |
require 'fastercsv' | |
def get_all_option_values(page, attr_name) | |
page.search("[name=#{attr_name}]").search("option").map do |opt| | |
option_value = opt.attribute("value").value | |
[option_value, opt.text.strip.gsub(/\302\240\302\240/, '')] if option_value && option_value.length > 0 | |
end.compact | |
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
# gem "prawn", "0.8.4" | |
# Sometime there is no enough space for the last table row when it reaches the end of page | |
Prawn::Document.generate("text_group_overflow_question.pdf") do |pdf| | |
add_page_break_if_overflow(pdf) do |pdf| | |
# generating table here | |
# ... | |
end | |
end |