Skip to content

Instantly share code, notes, and snippets.

View onigetoc's full-sized avatar

Gino onigetoc

View GitHub Profile
@bjrn
bjrn / scrollfix.html
Created February 1, 2012 21:54
IOS Webkit - native internal scroll - a fix for the document page-bounce
<!DOCTYPE html>
<html>
<!-- NOTES
Demo - uses IOS native scroll available in IOS5, but sidestep the document-bounce behavior.
another take on the solution first seen here: https://gist.github.com/1372229
https://github.com/joelambert/ScrollFix/issues/2
Tested on iPad 2, using IOS 5.0.1.
@use
use / gist:1756989
Created February 7, 2012 03:35
Post a card to Trello using the API
<?
$trello_key          = '123412341234123412341234';
$trello_api_endpoint = 'https://api.trello.com/1';
$trello_list_id      = '1234123412341234123412341234';
$trello_member_token = '12341234123412341234123412341234'; // Guard this well
 
$ch = curl_init("$trello_api_endpoint/cards");
curl_setopt_array($ch, array(
CURLOPT_SSL_VERIFYPEER => false, // Probably won't work otherwise
CURLOPT_RETURNTRANSFER => true, // So we can get the URL of the newly-created card
@Yavari
Yavari / README.markdown
Created February 23, 2012 09:00 — forked from gudbergur/README.markdown
Bootstrap's Typeahead plugin extended (allowing for AJAX functionality) among other things

This is a fork of Bootstrap Typeahead that adds minimal but powerful extensions.

For example, process typeahead list asynchronously and return objects

  # This example does an AJAX lookup and is in CoffeeScript
  $('.typeahead').typeahead(
    # source can be a function
    source: (typeahead, query) ->
 # this function receives the typeahead object and the query string
@weotch
weotch / gist:1959748
Created March 2, 2012 17:16
Running PHP scripts from CLI on Heroku
# Add this config
$ heroku config:add LD_LIBRARY_PATH=/app/php/ext:/app/apache/lib
# Login to Heroku CLI
$ heroku run bash
# The second argument here is the path to your script
~ $ ~/php/bin/php -f ~/www/index.php
<!doctype html>
<!-- http://taylor.fausak.me/2015/01/27/ios-8-web-apps/ -->
<html>
<head>
<title>iOS 8 web app</title>
<!-- CONFIGURATION -->
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@excalq
excalq / gist:2961415
Last active January 21, 2025 22:43
Javacript: Set or Update a URL/QueryString Parameter, and update URL using HTML history.replaceState()
// 2024 Update, use URLSearchParams [https://caniuse.com/urlsearchparams]
export function createQueryString2(name: string, value: string, searchParams: any) {
const params = new URLSearchParams(searchParams);
params.set(name, value.toLowerCase());
return params.toString();
}
// ---- Original 2012 version, when browsers really sucked ----
// Explicitly save/update a url parameter using HTML5's replaceState().
@ScottPhillips
ScottPhillips / remote-image-cache.php
Created July 7, 2012 07:16
Cache remote image using PHP
<?php
function cache_image($image_url){
//replace with your cache directory
$image_path = 'path/to/cache/dir/';
//get the name of the file
$exploded_image_url = explode("/",$image_url);
$image_filename = end($exploded_image_url);
$exploded_image_filename = explode(".",$image_filename);
$extension = end($exploded_image_filename);
//make sure its an image
@Goles
Goles / CountryCodes.json
Created July 29, 2012 05:37
Country and Dial or Phone codes in JSON format
[{"name":"Israel","dial_code":"+972","code":"IL"},{"name":"Afghanistan","dial_code":"+93","code":"AF"},{"name":"Albania","dial_code":"+355","code":"AL"},{"name":"Algeria","dial_code":"+213","code":"DZ"},{"name":"AmericanSamoa","dial_code":"+1 684","code":"AS"},{"name":"Andorra","dial_code":"+376","code":"AD"},{"name":"Angola","dial_code":"+244","code":"AO"},{"name":"Anguilla","dial_code":"+1 264","code":"AI"},{"name":"Antigua and Barbuda","dial_code":"+1268","code":"AG"},{"name":"Argentina","dial_code":"+54","code":"AR"},{"name":"Armenia","dial_code":"+374","code":"AM"},{"name":"Aruba","dial_code":"+297","code":"AW"},{"name":"Australia","dial_code":"+61","code":"AU"},{"name":"Austria","dial_code":"+43","code":"AT"},{"name":"Azerbaijan","dial_code":"+994","code":"AZ"},{"name":"Bahamas","dial_code":"+1 242","code":"BS"},{"name":"Bahrain","dial_code":"+973","code":"BH"},{"name":"Bangladesh","dial_code":"+880","code":"BD"},{"name":"Barbados","dial_code":"+1 246","code":"BB"},{"name":"Belarus","dial_code":"+375","
@vitalyrotari
vitalyrotari / device.js
Created August 2, 2012 12:41
Detect Mobile Devices
var Device = {
ENV_DESKTOP: 'desktop',
ENV_PHONE: 'phone',
ENV_TABLET: 'tablet',
ENV_PORTRAIT: 'portrait',
ENV_LANDSCAPE: 'landscape',
agent: {
mobile: (/iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile/i.test(window.navigator.userAgent.toLowerCase())),
tablet: (/ipad|android|android\s3\.0|xoom|sch-i800|playbook|tablet|kindle/i.test(window.navigator.userAgent.toLowerCase()))
},