Skip to content

Instantly share code, notes, and snippets.

View arigesher's full-sized avatar

Ari Gesher arigesher

View GitHub Profile
@arigesher
arigesher / inline-jquery-delay
Last active August 29, 2015 13:56
A dirty-but-effective method for getting inline script blocks to wait for a load of the JQuery library so they can use the superior API it offers. See http://ari.gesher.net/photos-the-gesher-world-tour/ for working example.
var waitForJquery = function(jqueryCallback, interval) {
if(typeof $ === 'function') {
jqueryCallback();
} else {
setTimeout(function() {
if(typeof $ === 'function'){
jqueryCallback();
} else {
waitForJquery(jqueryCallback, interval);
}
@arigesher
arigesher / responsive-flickr-embeds
Last active October 26, 2020 08:20
JQuery code to make Flickr embeds responsive (and resize correctly when loading in a mobile browser). See http://ari.gesher.net/photos-the-gesher-world-tour/ for a working example.
$(document).ready(function() {
$("#pics iframe").each(function(index) {
var ratio = $(this).height() / $(this).width();
var origHeight = $(this).height();
var origWidth = $(this).width();
var self = this;
// bind to window with closure that references the
// iframe since the iframe doesn't get resize events
// until (you know) we resize it.
$(window).resize(function() {
@arigesher
arigesher / flickrEmbeds
Created May 1, 2014 06:42
embeddable javascript file that will dynamically resize the height on flickr embeds to remove all black space and fit them into the container.
var waitForJquery = function(dofn, interval) {
if(typeof $ === 'function') {
dofn();
} else {
setTimeout(function() {
if(typeof $ === 'function'){
dofn();
} else {
waitForJquery(dofn, interval);
}
@arigesher
arigesher / -
Created May 2, 2014 18:50
Messing around with creating post notifications in Ghost (and learning Javascript)
diff --git a/Gruntfile.js b/Gruntfile.js
index 7a2cb02..d3edb52 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -245,6 +245,15 @@ var path = require('path'),
api: {
src: ['core/test/functional/api/*_test.js']
+ },
+ posts: {
@arigesher
arigesher / -
Created May 9, 2014 05:53 — forked from anonymous/-
decode binary string - python
for i in range(0,len(data),8):
bound = i+8
if i + 8 > len(data):
bound = len(data) - 1
byte = data[i+1:bound]
val = int(byte,2)
out = '%s%c'%(out,val)
print out
@arigesher
arigesher / AtlasWork-partial.java
Created August 6, 2014 23:03
Trivial example of an AtlasDB transaction
public class AtlasWork implements TransactionTask<SomeReturnType,Exception> {
public SomeReturnType execute(Transtaction t) throws Exception {
// this is the implicit start to the transaction
Charset UTF8 = Charset.forName("UTF-8");
byte[] tableName = "exampleTable".getBytes(UTF8);
byte[] rowId = "exampleRow".getBytes(UTF8);
@arigesher
arigesher / TransactionsAPIOverview.java
Created August 6, 2014 23:05
Overview of the Transactions API for AtlasDB
public interface Transaction {
/**
* Selects a one or more rows, each consisting of multiple cells.
*/
SortedMap<byte[], RowResult<byte[]>> getRows(String tableName, Iterable<byte[]> rows,
ColumnSelection columnSelection);
/**
* Selects specific cells (a Cell is a tuple of row id and field id)
*/
@arigesher
arigesher / sector_highlights.html
Created November 1, 2014 23:08
d3 demo of sector highlighting code
<html>
<head>
<body style='align: center'>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class='content' style='margin: auto'>
</div>
<script>
var data =
[
@arigesher
arigesher / find_value.coffee
Last active August 29, 2015 14:25
Snippet to recursively search a JSON structure for a leaf value - returns the path
find_value = (haystack, needle, cache=new WeakMap()) ->
# console.log "haystack: ", haystack
# console.log "needle: ", needle
try
if haystack?
unless typeof haystack == 'object' and cache.has haystack
cache.set haystack, true
for key, value of haystack
@arigesher
arigesher / -
Created January 19, 2016 00:23
This file has been truncated, but you can view the full file.
==> Installing qgis from homebrew/science
==> Downloading http://qgis.org/downloads/qgis-1.8.0.tar.bz2
Already downloaded: /Library/Caches/Homebrew/qgis-1.8.0.tar.bz2
==> Verifying qgis-1.8.0.tar.bz2 checksum
tar xvf /Library/Caches/Homebrew/qgis-1.8.0.tar.bz2
x qgis-1.8.0/
x qgis-1.8.0/.gitignore
x qgis-1.8.0/.mailmap
x qgis-1.8.0/BUGS