Skip to content

Instantly share code, notes, and snippets.

View sterlingwes's full-sized avatar
🍉

Wes Johnson sterlingwes

🍉
View GitHub Profile
@misfo
misfo / symbol_literals.rb
Created July 8, 2011 20:05
valid Symbol literal characters in Ruby
$ ruby -v
ruby 1.9.2p136 (2010-12-25)
$ ruby symbol_literals.rb
valid as first char:
@$_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
valid as middle char:
_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
valid as end char:
!_=?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
@dhavaln
dhavaln / index.html
Created June 7, 2012 05:44
Include Phonegap/Cordova JS based on the Device
<!DOCTYPE HTML>
<html>
<!DOCTYPE HTML>
<head>
<meta name="viewport" content="width=320; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>PhoneGap Test</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.css" >
<script type="text/javascript" charset="utf-8"
@adamawolf
adamawolf / Apple_mobile_device_types.txt
Last active May 3, 2024 17:56
List of Apple's mobile device codes types a.k.a. machine ids (e.g. `iPhone1,1`, `Watch1,1`, etc.) and their matching product names
i386 : iPhone Simulator
x86_64 : iPhone Simulator
arm64 : iPhone Simulator
iPhone1,1 : iPhone
iPhone1,2 : iPhone 3G
iPhone2,1 : iPhone 3GS
iPhone3,1 : iPhone 4
iPhone3,2 : iPhone 4 GSM Rev A
iPhone3,3 : iPhone 4 CDMA
iPhone4,1 : iPhone 4S
@damncabbage
damncabbage / factories.js
Created August 16, 2012 01:52
FactoryGirl-ish definitions in Jasmine
/*
* Set up factories, then create them in tests with (for example):
*
* LineItemFactory();
*
* Or with attributes / overrides:
*
* LineItemFactory({
* "id": 123,
* "order": OrderFactory({"firstName": "Example Associated Record Override"}),
@thomseddon
thomseddon / gist:3834721
Created October 4, 2012 16:21
AngularJS: Avoid redirection loop in legacy browser (IE) with HTML5 mode
var buggyAndroid = parseInt((/android (\d+)/.exec(window.navigator.userAgent.toLowerCase()) || [])[1], 10) < 4;
if (!history.pushState || buggyAndroid) {
if (window.location.hash) {
if(window.location.pathname !== '/') window.location.replace('/#!' + window.location.hash.substr(2)); //Hash and a path, just keep the hash (redirect)
} else {
window.location.replace('/#!' + window.location.pathname); //No hash, take path
}
}
//And then in app.config:
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active May 2, 2024 05:55
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

# Support running Whenever cron jobs with Lockrun
# Lockrun: http://www.unixwiz.net/tools/lockrun.html
# lockrun typically installed at /usr/bin/lockrun
# On Mac, install with: brew install lockrun
# Lockrun prefix for cronjobs: /usr/bin/lockrun --lockfile=/path/to/tmp/JOBNAME.lockrun -- sh -c "COMMAND"
def wrap_with_lockrun command
"/usr/bin/env lockrun --lockfile=:path/tmp/:lockfile.lockrun -- sh -c \"#{ command }\""
end
#redefine the three default job types to use Lockrun (i.e. just add 'lockrun_' in front of the existing job names)
@bgrins
bgrins / Log-.md
Last active August 1, 2023 16:32
Prevent errors on console methods when no console present and expose a global 'log' function.

Javascript log Function

Every time I start a new project, I want to pull in a log function that allows the same functionality as the console.log, including the full functionality of the Console API.

There are a lot of ways to do this, but many are lacking. A common problem with wrapper functions is that the line number that shows up next to the log is the line number of the log function itself, not where log was invoked. There are also times where the arguments get logged in a way that isn't quite the same as the native function.

This is an attempt to once and for all document the function that I pull in to new projects. There are two different options:

  • The full version: Inspired by the plugin in HTML5 Boilerplate. Use this if you are writing an application and want to create a window.log function. Additionally,
@gabrielhpugliese
gabrielhpugliese / meteor-windows-vagrant-tutorial.md
Last active April 19, 2022 14:37
Tutorial for running Meteor in Windows using Vagrant

Tutorial: Meteor in Windows using Vagrant

BEFORE YOU CONTINUE:

  • Now, Meteor runs in any Windows without any line of this tutorial. Just download the Meteor binary! Yay!!
  • mrt is no longer used with Meteor 1.0

These days some people were discussing at meteor-talk group about running Meteor at Windows and I’ve recommended them using Vagrant. It’s a very developer-friendly piece of software that creates a virtual machine (VM) which let you run any operating system wanted and connect to it without big efforts of configuration (just make the initial installation and you have it working).

Many packages (I've tested) for running Meteor+Vagrant fails because Meteor writes its mongodb file and also other files inside local build folder into a shared folder between the Windows host and the Linux guest, and it simply does not work. So I've put my brain to work and found a solution: do symlinks inside the VM (but do not use ln. Use mount so git can follow it). It’s covered on