Skip to content

Instantly share code, notes, and snippets.

/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@alphabet
alphabet / config.ru
Last active September 2, 2015 13:47 — forked from nathany/config.ru
Magical Unicorn Configuration for Heroku
# add something like this to config.ru
# see https://github.com/kzk/unicorn-worker-killer
if Integer(ENV['UNICORN_KILLER'] || 0) != 0
require 'unicorn/worker_killer'
# Max memory size (RSS) per worker
use Unicorn::WorkerKiller::Oom, (350*(1024**2)), (400*(1024**2)), 30, true
end
@alphabet
alphabet / gist:f7485947fe4c4e6733ee
Last active September 8, 2015 15:51 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@alphabet
alphabet / web-servers.md
Created March 2, 2016 21:32 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@alphabet
alphabet / storagePolyfill.js
Last active May 19, 2016 15:17 — forked from jarrodirwin/storagePolyfill.js
LocalStorage/SessionStorage Polyfill with Safari Private Browsing support.
// alphabet work derived from https://gist.github.com/remy/350433
try {
// Test webstorage existence.
if (!window.localStorage || !window.sessionStorage) throw "exception";
// Test webstorage accessibility - Needed for Safari private browsing.
localStorage.setItem('storage_test', 1);
localStorage.removeItem('storage_test');
} catch(e) {
(function () {
var Storage = function (type) {
Note 1: The following CQ curl commands assumes a admin:admin username and password.
Note 2: For Windows/Powershell users: use two "" when doing a -F cURL command.
Example: -F"":operation=delete""
Note 3: Quotes around name of package (or name of zip file, or jar) should be included.
Uninstall a bundle (use http://localhost:4505/system/console/bundles to access the Apache Felix web console)
curl -u admin:admin -daction=uninstall http://localhost:4505/system/console/bundles/"name of bundle"
Install a bundle
curl -u admin:admin -F action=install -F bundlestartlevel=20 -F
@alphabet
alphabet / page_tag_embed_widgets.html
Created June 15, 2017 17:31 — forked from JeffTD/page_tag_embed_widgets.html
Using page tags to control embed codes
// To create a reliable string of page tags to use for comparison in Liquid conditional statements, place this in layout.html between the <head> and <body>:
{% assign tags_list = "" %}
{% for tag in page.tags %}
{% assign tags_list = tag.name | append: ", " | append: tags_list %}
{% endfor %}
// We'll need a consistent tag naming convention that contains a 'trigger' phrase and an 'id' to use in the link to the embedded widget.
// In this case, we need an ID for a Phone2Action widget, so we'll be using the tag format 'p2a-12345'
//
@alphabet
alphabet / README.md
Created August 13, 2018 17:44 — forked from barneycarroll/README.md
Lock and unlock a page's scroll position.

jquery.scrollLock.js

Useful for when a blocking user experience is needed (in my case, didn't want people unwittingly loosing their place by scrolling while a modal required their attention): $.scrollLock() locks the body in place, preventing scroll until it is unlocked.

// Locks the page if it's currently unlocked
$.scrollLock();

// ...or vice versa
@alphabet
alphabet / .htaccess
Created November 6, 2018 20:19 — forked from tunght13488/.htaccess
htaccess IP whitelisted rule behind load balancer
# See: http://www.jonathanquail.com/blog/2012/05/09/restricting-access-to-servers-behind-an-elastic-load-balancer/
# Extract client IP
#SetEnvIf REMOTE_ADDR "(.+)" CLIENTIP=$1
# If request is forwarded, use forwarded IP instead
SetEnvIf X-Forwarded-For "^([0-9.]+)" CLIENTIP=$1
# If request is not forwarded, set a flag
SetEnvIf X-Forwarded-For "^$" is_not_forwarded
# Whitelist
SetEnvIf CLIENTIP "173.55.53.87" allowed_in
SetEnvIf CLIENTIP "72.67.47.197" allowed_in
@alphabet
alphabet / us-state-ansi-fips.csv
Created May 14, 2021 21:16 — forked from dantonnoriega/us-state-ansi-fips.csv
csv file of us state ansi fips codes that follows the us census variable names
stname st stusps
Alabama 01 AL
Alaska 02 AK
Arizona 04 AZ
Arkansas 05 AR
California 06 CA
Colorado 08 CO
Connecticut 09 CT
Delaware 10 DE
District of Columbia 11 DC