Skip to content

Instantly share code, notes, and snippets.

@bryanjswift
bryanjswift / UAgentInfo.java
Created March 1, 2010 09:43
User Agent detection in Java
/* *******************************************
// LICENSE INFORMATION
// The code, "Detecting Smartphones Using PHP"
// by Anthony Hand, is licensed under a Creative Commons
// Attribution 3.0 United States License.
//
// Updated 01 March 2010 by Bryan J Swift
// - Remove un-needed if statements instead just returning the boolean
// inside the if clause
//
@bryanjswift
bryanjswift / ec2-dns.rb
Created December 2, 2010 04:55
Print out useful information about running ec2 instances
#!/usr/bin/env ruby
#
# This ruby script will print out useful information about running ec2
# instances
#
# Reads AWS access and secret keys from environment variables
#
# Requires the amazon-ec2 gem (gem install amazon-ec2)
#
# Author: Bryan J Swift (bryan.j.swift@gmail.com)
@3n
3n / onPause.js
Created January 13, 2011 23:52
defines :delay(time) pseudo for Element.Event in MooTools
We couldn’t find that file to show.
package com.banksimple.util
private[util] final class Effectful[T](val origin: T) {
/**
* A special case of doto, andAlso is useful for
* quick logging or output tasks. Similar in use
* to doto, but only takes one function.
* */
def andAlso(x: T => Unit): T = { x(origin) ; origin }
@mindscratch
mindscratch / log4r_mixin.rb
Created August 15, 2011 09:28
log4r mixin
module Logging
# Get an instance to a logger configured for the class that includes it.
# This allows log messages to include the class name
def logger
return @logger if @logger
formatter = Log4r::PatternFormatter.new(:pattern => '[%d] %l %C: %M')
@logger = Log4r::Logger.new(self.class.name)
@JeffreyWay
JeffreyWay / gist:1525217
Created December 27, 2011 21:29
Instant Server for Current Directory
alias server='open http://localhost:8000 && python -m SimpleHTTPServer'
@scottjehl
scottjehl / tmplmeta.md
Created January 25, 2013 18:37
Template meta tag pattern for template-based decisions

I've been finding this little meta[name='tmpl'] pattern useful lately when making template-based decisions in JS, such as when loading a particular file or set of files that are needed only on a particular page of a site.

First, in the HTML of a particular template, like say, a search result page:

<head>
  ...
  <meta name="tmpl" content="searchresult">
</head>
@igable
igable / watch.rb
Last active December 31, 2015 16:29
The code below is taken entirely from a post by Brett Terpstra located at: http://brettterpstra.com/2011/03/07/watch-for-file-changes-and-refresh-your-browser-automatically/ This version below is modified to work better with Jekyll (see comment below)
#!/usr/bin/env ruby
# watch.rb by Brett Terpstra, 2011 <http://brettterpstra.com>
# with credit to Carlo Zottmann <https://github.com/carlo/haml-sass-file-watcher>
trap("SIGINT") { exit }
if ARGV.length < 2
puts "Usage: #{$0} watch_folder keyword"
puts "Example: #{$0} . mywebproject"
exit
package com.android.workaround;
import android.app.Activity;
import android.graphics.Rect;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
/**
* When an {@link Activity} is launched with
/**
* Hypertext Transfer Protocol (HTTP) response status codes.
*
* @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}
*/
export enum HttpStatusCode {
/**
* The server has received the request headers and the client should proceed to send the request body
* (in the case of a request for which a body needs to be sent; for example, a POST request).