Skip to content

Instantly share code, notes, and snippets.

View gblazex's full-sized avatar

Blaze (Balázs Galambosi) gblazex

View GitHub Profile
@eligrey
eligrey / readme.md
Created September 13, 2009 19:51
High-resolution JavaScript timer
@remy
remy / gist:349069
Created March 30, 2010 12:46
Early version of XUI native animations with drop back on to Emile/timer based
(function ($, window, undefined) {
var m = document.createElement('i'),
m_style = m.style,
// TODO support other browsers easings - based on Safari's easing options and ported to Emile easing.
stanardEasing = {
'ease-in-out' : function(pos){if((pos/=0.5)<1){return 0.5*Math.pow(pos,4);}return -0.5*((pos-=2)*Math.pow(pos,3)-2);},
'ease-in' : function(pos){return Math.pow(pos,4);},
'ease-out' : function(pos){return Math.pow(pos,0.25);},
'linear': function (i) {return i;}
<html>
<head>
<title>TouchEvent detection for iPhone/iPod/iPad</title>
<script type="text/javascript">
var isTouch = (function() {
var event, feature = false,
support = function() { feature = true; },
element = document.createElement('div');
@remy
remy / gist:539433
Created August 20, 2010 02:01
Random hex colour with correct padding for small colours
(function(h){return '#000000'.substr(0,7-h.length)+h})((~~(Math.random()*(1<<24))).toString(16))
@eligrey
eligrey / README.md
Created August 11, 2011 01:41
An external resource request function for modern (i.e. BlobBuilder-supporting) browsers and FF5.

API

XMLHttpRequest request({
    String url
    // type can be buffer, blob, text, or document
    optional String type = "buffer"
    optional String|ArrayBuffer|Blob|FormData|Document data
    optional Function callback(type data)

optional Function onerror()

@tomohisa
tomohisa / NSArray+IndexHelper.h
Created July 8, 2012 06:53
Using ObjectAtIndex safely with this method.
//
// NSArray+IndexHelper.h
// C_POS
//
// Created by Tomohisa Takaoka on 6/14/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@gblazex
gblazex / BLZLabelWithInset.h
Created March 4, 2016 10:33
BLZLabelWithInset - simple UILabel subclass with inset
@interface BLZLabelWithInset : UILabel
@property (nonatomic) UIEdgeInsets insets;
@end
@mttrb
mttrb / NSArray+NegativeIndexes.m
Created November 15, 2012 02:54
Objective-C Literals: Negative Array Subscripts
//
// NSArray+NegativeIndexes.m
// Allow Negative Array Literals
//
// Created by Matthew Robinson on 25th October 2012.
// Copyright (c) 2012 Matthew Robinson. All rights reserved.
//
// WARNING: This is a proof of concept and should not be used
// in production code. This could break at anytime.
@jed
jed / LICENSE.txt
Created May 25, 2011 14:15 — forked from 140bytes/LICENSE.txt
select DOM elements by ID, tag name, or class name
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@gblazex
gblazex / promise_preferred.js
Created November 22, 2016 21:37
Promise.preferred
// Promises are started in parallel.
// Resolves with the first resolved value in array order.
// If there's no winner, it rejects with last rejection.
Promise.preferred = function (promisesOrdered) {
return new Promise((resolve, reject) => {
var resolvedValues = new WeakMap();
var resolvables = promisesOrdered.slice(); // copy
function onMemberResolved(value, member) {
resolvedValues.set(member, value);
if (member == resolvables[0])