Skip to content

Instantly share code, notes, and snippets.

View htom78's full-sized avatar

htom78

View GitHub Profile
@zerowidth
zerowidth / paginated_collection.js
Created November 18, 2010 22:04
first whack at pagination with backbone.js
// includes bindings for fetching/fetched
PaginatedCollection = Backbone.Collection.extend({
initialize: function() {
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage');
this.page = 1;
},
fetch: function(options) {
options || (options = {});
this.trigger("fetching");
// Original code from http://www.blog.highub.com/mobile-2/a-fix-for-iphone-viewport-scale-bug/
var metas = document.getElementsByTagName('meta');
var i;
if (navigator.userAgent.match(/iPhone/i)) {
for (i=0; i<metas.length; i++) {
if (metas[i].name == "viewport") {
metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
}
}
@mklabs
mklabs / bootstrap-plugins.txt
Created December 2, 2011 11:23
h5bp + twitter bootstrap integration
bootstrap-tooltip.js
bootstrap-popover.js
bootstrap-alert.js
bootstrap-button.js
bootstrap-carousel.js
bootstrap-collapse.js
bootstrap-dropdown.js
bootstrap-modal.js
bootstrap-scrollspy.js
bootstrap-tab.js
@bmsterling
bmsterling / collections_tags.js
Created December 29, 2011 03:54
Pagination of a large set of models. The full story can be found at http://benjaminsterling.com/pagination-and-backbone-js/
(function (collections, pagination, model) {
collections.Tags = Backbone.Collection.extend({
model : model,
url : 'tags_all.php',
/**
* @param resp the response returned by the server
* @returns (Array) tags
*/
parse : function (resp) {
@joewest
joewest / didRequestRange.js
Created January 13, 2012 20:14
Ember.PaginationSupport
App.collectionController = Em.ArrayProxy.create(Ember.PaginationSupport, {
content: [],
fullContent: App.store.findAll(App.Job),
totalBinding: 'fullContent.length',
didRequestRange: function(rangeStart, rangeStop) {
var content = this.get('fullContent').slice(rangeStart, rangeStop);
this.replace(0, this.get('length'), content);
}
});
@htom78
htom78 / .vimrc
Created April 20, 2012 06:59 — forked from cloud8421/.vimrc
Set up Vim on Mac or Linux. curl https://raw.github.com/gist/2426726/vim.sh | sh
" this is the configuration file for linux and mac systems
" symlink this to your home folder as .vimrc
" It loads pathogen and loads all modules from ~/.vim/bundles.
" It then loads ~/.vimrc_main which has the main
" configuration that works across all systems.
call pathogen#runtime_prepend_subdirectories(expand('~/.vim/bundles'))
call pathogen#helptags()
source ~/.vimrc_main
@kejun
kejun / gist:3358036
Created August 15, 2012 09:23
ios/android兼容mouse事件
;(function($){
$.support.touch = 'ontouchend' in document;
if (!$.support.touch) {
return;
}
var eventMap = {
click: 'touchend',
mousedown: 'touchstart',
@htom78
htom78 / gist:4265417
Created December 12, 2012 06:16 — forked from lucifr/gist:1208100
#!/usr/bin/env python
# coding:utf-8
import _env
from time import time
from urllib import urlencode
from urllib2 import urlopen as urlopen2
from urlparse import parse_qsl
from hashlib import md5
from urlgrabber import urlopen
import errno
<?php
class PassAPI extends Plugin
{
# Registration
# register a device to receive push notifications for a pass
#
# POST /v1/devices/<deviceID>/registrations/<typeID>/<serial#>
# Header: Authorization: ApplePass <authenticationToken>
# JSON payload: { "pushToken" : <push token, which the server needs to send push notifications to this device> }
#