Skip to content

Instantly share code, notes, and snippets.

View joshuapinter's full-sized avatar
🎯
Focusing

Joshua Pinter joshuapinter

🎯
Focusing
View GitHub Profile
@shunchu
shunchu / convert-seconds-into-hh-mm-ss-in-ruby.rb
Created July 25, 2012 07:58
Convert seconds into HH:MM:SS in Ruby
t = 236 # seconds
Time.at(t).utc.strftime("%H:%M:%S")
=> "00:03:56"
# Reference
# http://stackoverflow.com/questions/3963930/ruby-rails-how-to-convert-seconds-to-time
@thbar
thbar / _readme.md
Created May 28, 2012 15:17
Global "spinner" with jQuery, KnockOut.js and CoffeeScript

I wanted a quick "data is synchronizing" global spinner for WiseCash - here is what I came up with.

@mcasimir
mcasimir / static_map_helper.rb
Created May 24, 2012 01:32
Google Maps Static map helper for Ruby on Rails
module StaticMapHelper
def static_map_for(location, options = {})
params = {
:center => [location.lat, location.lng].join(","),
:zoom => 15,
:size => "300x300",
:markers => [location.lat, location.lng].join(","),
:sensor => true
}.merge(options)
@rduplain
rduplain / MainActivity.java
Created May 8, 2012 20:08
A very simple full-screen WebView activity for Android native wrappers, as a starting point.
package com.willowtreeapps.demo;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Window;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends Activity {
@kconragan
kconragan / keyrepeat.shell
Last active December 4, 2023 03:40
Enable key repeat in Apple Lion for Sublime Text in Vim mode
# Mac OS X Lion introduced a new, iOS-like context menu when you press and hold a key
# that enables you to choose a character from a menu of options. If you are on Lion
# try it by pressing and holding down 'e' in any app that uses the default NSTextField
# for input.
#
# It's a nice feature and continues the blending of Mac OS X and iOS features. However,
# it's a nightmare to deal with in Sublime Text if you're running Vintage (Vim) mode,
# as it means you cannot press and hold h/j/k/l to move through your file. You have
# to repeatedly press the keys to navigate.
@9re
9re / ExifUtil.java
Created March 7, 2012 00:16
fix flipped / rotated image by getting exif orientation
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.os.Build;
@jeremy2
jeremy2 / database.yml.erb
Created March 6, 2012 23:17
Engine Yard custom Chef Recipe for generating database.yml configuration file
#
# This file should be in .../cookbooks/database/templates/default/database.yml.erb
#
<%= @environment %>:
adapter: <%= @adapter %>
database: <%= @database %>
username: <%= @username %>
password: <%= @password %>
host: <%= @host %>
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@chuckbergeron
chuckbergeron / external_resource.rb
Created November 24, 2011 18:18
ExternalResource
module ExternalResource
# TODO: handle: Timeout::Error (time's up!):
# Requires a block with the HTTPClient.get call or what-have-you
# see InvitationRequestsController for details
def self.load( name = "" )
retries = 12
total = retries
set :application, "application"
set :deploy_to, "/var/www/application"
set :deploy_via, "remote_cache"
set :scm, :subversion
set :repository, "http://account.svn.beanstalkapp.com/repository/trunk"
set :scm_user, "deploy_dummy"
set :scm_password, File.read("#{ENV['HOME']}/.application_deployment_password").strip