I hereby claim:
- I am jamesdaniels on github.
- I am jamesuriah (https://keybase.io/jamesuriah) on keybase.
- I have a public key whose fingerprint is 0A16 8002 F444 EBE3 33C2 6A36 2C95 8E6B A90B 5CE5
To claim this, I am signing this object:
# Returns either true or false depending on whether or not the user agent of | |
# the device making the request is matched to a device in our regex. | |
def is_mobile_device? | |
request.user_agent.to_s.downcase =~ /silk|palm|blackberry|nokia|phone|midp|mobi|symbian|chtml|ericsson|minimo|audiovox|motorola|samsung|telit|upg1|windows ce|ucweb|astel|plucker|x320|x240|j2me|sgh|portable|sprint|docomo|kddi|softbank|android|mmp|pdxgw|netfront|xiino|vodafone|portalmmm|sagem|mot-|sie-|ipod|up\\.b|webos|amoi|novarra|cdm|alcatel|pocket|ipad|iphone|mobileexplorer|mobile/ | |
end | |
# Can check for a specific user agent | |
# e.g., is_device?('iphone') or is_device?('mobileexplorer') | |
def is_device?(type) |
// Pattern *support.appblade.com\/login\/new | |
$('#user_session_email').val('USERNAME'); | |
$('#user_session_password').val('PASSWORD')[0].form.submit(); |
// This will grab the largest image for the pixelRatio without oversampling (iOS style) | |
// Usage: assetUsingNativePixelRatio('/assets/images', 'logo', 'png', [1,2,3]); | |
// Output: /assets/images/logo@2x.png | |
function assetUsingNativePixelRatio(path, name, extension, pixelRatios) { | |
// Sort the pixelRatios in case they were put in the wrong order | |
var $pixelRatios = $(pixelRatios).sort(); | |
// Price is right style | |
var matchingPixelRatio = $pixelRatios.not(function() { |
I hereby claim:
To claim this, I am signing this object:
`exiftool /Users/james/Desktop/james.psd`.split("\n").collect{|a| | |
[ | |
(array = a.split(':')).first.strip, | |
(array.shift && array).join(':').strip | |
] | |
} |
def verifed_facebook_autheticity(signature, params) | |
Digest::MD5.hexdigest((params.keys.sort.collect {|key| "#{key}=#{params[key]}"} << APP_CONFIG[:facebook_api_secret]).to_s).strip == signature | |
end |
# .gitattributes | |
*.pbxproj -crlf -diff -merge | |
# .gitignore | |
# xcode noise | |
build/* | |
*.pbxuser |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> | |
<head> | |
<script src="http://static.ak.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script> | |
</head> | |
<body> |
class Circuit | |
def initialize(resistors) | |
@resistors = resistors | |
@final_node = 0 | |
@resistors.each do |(source, destination, resistance)| | |
@final_node = [@final_node, source, destination].max | |
end |
class Polynomial | |
def initialize(coefficients) | |
@coefficients = coefficients.reverse # reverse so the index equates to the exponent of each coefficient | |
raise ArgumentError, 'Need at least 2 coefficients' if coefficients.size < 2 | |
end | |
def to_s | |
# Build an array of sprintfs, LIFO to get most significant order | |
@coefficients.inject([]) {|builder, coefficient| ["%+ix^%i" % [coefficient, builder.size]] + builder}.to_s. | |
gsub(/(\+0x\^\d+|x\^0|\^1\d{0})/, ''). # Clean out 0x^y, x^0, ^1 | |
gsub(/\d{0}1x/, 'x'). # Replace 1x with just x |