Skip to content

Instantly share code, notes, and snippets.

View am's full-sized avatar
🌊
surfing bits and bytes

antonio miranda am

🌊
surfing bits and bytes
View GitHub Profile
@paullewis
paullewis / requestIdleCallback.js
Last active February 21, 2024 16:56
Shims rIC in case a browser doesn't support it.
/*!
* Copyright 2015 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@leipert
leipert / detectBrowserLanguage.js
Last active March 11, 2024 02:10 — forked from anonymous/detectBrowserLanguage.js
Detect browser language in javascript (utilizing lodash)
// These window.navigator contain language information
// 1. languages -> Array of preferred languages (eg ["en-US", "zh-CN", "ja-JP"]) Firefox^32, Chrome^32
// 2. language -> Preferred language as String (eg "en-US") Firefox^5, IE^11, Safari,
// Chrome sends Browser UI language
// 3. browserLanguage -> UI Language of IE
// 4. userLanguage -> Language of Windows Regional Options
// 5. systemLanguage -> UI Language of Windows
var browserLanguagePropertyKeys = ['languages', 'language', 'browserLanguage', 'userLanguage', 'systemLanguage'];
@tyler-johnson
tyler-johnson / README.md
Last active February 8, 2016 14:08
Simple Browserify middleware for Express with basic in-memory caching and watchify support.

Simple Browserify middleware for Express with basic in-memory caching and watchify support.

I created this as a Gist instead of Node module because Browserify bundles are one of those things better left customizable. This function, as it stands, is very limited. It has no support for things like transforms and plugins. Copy this into your app and add any desired functionality there.

Depends on:

  • Browserify - tested on v6.1, expected to work on v4.0+
  • Watchify - tested on v2.0, expected to work on v1.0+. Watchify is optional. Remove watchify require statement if not desired.
  • Express - tested with v4.9, expected to work with v3.0+

Usage

@MrOrz
MrOrz / xdomainrequest.js.coffee
Created September 1, 2013 16:07
Patching `XMLHttpRequest` for AngularJS and Internet Explorer < 10. It replaces the original `window.XMLHttpRequest` with a thin interface that only implements the parts AngularJS core uses. Missing methods of `XDomainRequest` are fed with `angular.noop`.
# A XMLHttpRequest wrapper for IE < 10.
# When it comes to cross domain ajax requests, it uses XDomainRequest instead.
# ** Only supports GET and POST requests! **
# Targeting IE < 10
# https://github.com/amcintyre-cs/strophejs-plugins/commit/b0a6ff2571bb70dd2f6f65c46034f4e47d75d564
return unless window.XDomainRequest and !("withCredentials" in window.XMLHttpRequest)
OriginalXMLHttpRequest = window.XMLHttpRequest
window.location.origin ?= window.location.protocol + '//' + window.location.host
@jhbabon
jhbabon / cleanup.rb
Created February 14, 2013 16:33
Clean all INSERT command from a mysql dump with grep and ruby
#!/usr/bin/env ruby
# @see http://stackoverflow.com/a/11522507
if ARGV.empty?
$stdout.puts "Usage: cleanup.rb dump.sql table_a [table_b ...]"
else
args = ARGV.reverse
file = args.pop
@jordelver
jordelver / gist:3139365
Created July 18, 2012 22:29
How to write an image file to an SD card under Mac OS X (for Raspberry Pi)

Find the SD card device

In this case, the SD card is /dev/disk4. DO NOT get this wrong or you may destroy all the data on the wrong disk/card/drive.

diskutil list

/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *160.0 GB   disk0

1: EFI 209.7 MB disk0s1

@singuerinc
singuerinc / gist:2586417
Created May 3, 2012 15:18
Adding an App to a Facebook Page
//Facebook Page administrators can add your app directly to their Page by navigating to the following URL:
https://www.facebook.com/dialog/pagetab?app_id=YOUR_APP_ID&next=YOUR_URL
//where YOUR_APP_ID and YOUR_URL can be found in your app settings.
https://developers.facebook.com/docs/appsonfacebook/pagetabs/
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt