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
# Given some text, write a function to find the max word letter span and list of words with that span | |
# Word letter span is defined as the alphabetical distance in between the first and last letters of the word | |
# Rules | |
# The same two letters produce the same span regardless of their order in the word | |
#. “PAT” and “TAP” have span 4 | |
# Capitalization does not matter | |
#. “Pat” and “pat” have span 4 | |
# Words that begin and end with the same letter have a word span of 0 |
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
task :review_app_setup do | |
GOB_DEV_DOMAIN = #<our-custom-domain-for-dev> | |
require "dnsimple" | |
require "platform-api" | |
heroku_app_name = ENV["HEROKU_APP_NAME"] | |
dnsimple_account_id = ENV["DNSIMPLE_DEV_ACCOUNT_ID"] | |
type = { type: 'CNAME' } |
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
export PS1="\[\033[36m\]\u:\[\033[32m\]\w\[\033[33m\]\$(markup_git_branch \$(parse_git_branch))\[\033[00m\]$ " | |
parse_git_branch() { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* (*\([^)]*\))*/\1/' | |
} | |
markup_git_branch() { | |
if [[ -n $@ ]]; then | |
if [[ -z $(git status --porcelain 2> /dev/null) ]]; then | |
echo -e ":\001\033[32m\002($@)\001\033[0m\002" |
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
# This snippet can be included in ApplicationController.rb | |
if Rails.env.production? | |
rescue_from StandardError do |error| | |
# if it is an unrecoverable error, send a signal to heroku | |
# to restart the infrastructure | |
if error.message =~ /deadlock; recursive locking/ | |
hclient = PlatformAPI.connect_oauth(ENV["HEROKU_API_TOKEN"]) | |
heroku_app, dyno = "name-of-your-app", hclient.dyno | |
# avoid sending the signal more than once | |
if dyno.list(heroku_app).dig(0, "state") === "up" |
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
/** | |
* | |
*/ | |
package com.bwuit.app.activities; | |
import java.io.BufferedReader; | |
import java.io.InputStreamReader; | |
import java.net.HttpURLConnection; | |
import java.net.URL; |
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
class Instagram < PM::WebScreen | |
title "Instagram" | |
CLIENT_ID = 'your client id' | |
REDIRECT_URI = 'http://your.domain.com/auth/instagram/callback' | |
FAILURE_URL = 'http://your.domain.com/auth/failure' | |
AUTH_URI = "https://instagram.com/oauth/authorize/?client_id=#{CLIENT_ID}&redirect_uri=#{REDIRECT_URI}&response_type=token" | |
class << self | |
def api |
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
# add next to your Rakefile | |
app.info_plist['UIViewControllerBasedStatusBarAppearance'] = false | |
app.info_plist['UIStatusBarStyle'] = 'UIStatusBarStyleLightContent' |
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
DecentExposure::ActiveRecordStrategy#plural? delegated to inflector.plural?, but inflector is nil: #<DecentExposure::ActiveRecordWithEagerAttributesStrategy:0x007fba64bba870 @controller=#<HomeController:0x007fba6b051338 @_routes=nil, @_action_has_layout=true, @_headers={"Content-Type"=>"text/html"}, @_status=200, @_request=#<ActionDispatch::Request:0x007fba6b051220 @env={"REMOTE_ADDR"=>"127.0.0.1", "REQUEST_METHOD"=>"GET", "REQUEST_PATH"=>"/", "PATH_INFO"=>"/", "REQUEST_URI"=>"/", "SERVER_PROTOCOL"=>"HTTP/1.1", "HTTP_VERSION"=>"HTTP/1.1", "HTTP_HOST"=>"localhost:3000", "HTTP_CONNECTION"=>"keep-alive", "HTTP_CACHE_CONTROL"=>"max-age=0", "HTTP_ACCEPT"=>"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "HTTP_USER_AGENT"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.66 Safari/537.36", "HTTP_ACCEPT_ENCODING"=>"gzip,deflate,sdch", "HTTP_ACCEPT_LANGUAGE"=>"es-ES,es;q=0.8", "HTTP_COOKIE"=>"request_method=GET; _ixclu_session=Nmp6THR |
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 GCM = require('./gcm'); | |
var gcm = new GCM(<YOUR GOOGLE API KEY>); // https://code.google.com/apis/console | |
// create the message | |
var msg = { | |
registration_ids: [token], // this is the device token (phone) | |
collapse_key: "your_collapse_key", // http://developer.android.com/guide/google/gcm/gcm.html#send-msg | |
time_to_live: 180, // just 30 minutes | |
data: { |
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 ws = new WebSocket("ws://server:9876"); | |
ws.onopen = function() { ... }; | |
ws.onerror = function() { ... }; | |
ws.onclose = function() { ... }; | |
ws.onmessage = function(event) { event.data }; |
NewerOlder