Skip to content

Instantly share code, notes, and snippets.

View jcayzac's full-sized avatar

Julien Cayzac jcayzac

View GitHub Profile
@leovandriel
leovandriel / gist:3794804
Created September 27, 2012 15:59
NWURLConnection - an NSURLConnectionDelegate based on blocks with cancel
// NWURLConnection - an NSURLConnectionDelegate based on blocks with cancel.
// Similar to the `sendAsynchronousRequest:` method of NSURLConnection, but
// with `cancel` method. Requires ARC on iOS 6 or Mac OS X 10.8.
// License: BSD
// Author: Leonard van Driel, 2012
@interface NWURLConnection : NSObject<NSURLConnectionDelegate>
@property (nonatomic, strong) NSURLRequest *request;
@property (nonatomic, strong) NSOperationQueue *queue;
@adamgit
adamgit / .gitignore
Last active March 20, 2025 10:01
.gitignore file for Xcode4 / OS X Source projects
#########################
# .gitignore file for Xcode4 and Xcode5 Source projects
#
# Apple bugs, waiting for Apple to fix/respond:
#
# 15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation?
#
# Version 2.6
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
@jirutka
jirutka / rules-both.iptables
Created September 18, 2012 12:42
Basic iptables template for ordinary servers (both IPv4 and IPv6)
###############################################################################
# The MIT License
#
# Copyright 2012-2014 Jakub Jirutka <[email protected]>.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
var ParentClass = function() { }
ParentClass.prototype = {}
ParentClass.prototype.constructor = ParentClass;
var SubClass = function() {
ParentClass.prototype.constructor.apply(this, []);
};
SubClass.prototype = Object.create(ParentClass.prototype)
SubClass.prototype.constructor = SubClass
@jcayzac
jcayzac / gist:2252804
Created March 30, 2012 16:51
Google Charts API: TeX formulas to transparent PNG, over HTTPS
@nateps
nateps / gist:1172490
Created August 26, 2011 01:38
Hide the address bar in a fullscreen iPhone or Android web app
<!DOCTYPE html>
<meta charset=utf-8>
<meta name=viewport content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name=apple-mobile-web-app-capable content=yes>
<meta name=apple-mobile-web-app-status-bar-style content=black>
<title>Test fullscreen</title>
<style>
html, body {
margin: 0;
padding: 0;
/*
# Deflate compression using Canvas 2d API
Canvas API provides HTMLCanvasElement#toDataURL, which allows serialize canvas image to png image. I do not know about result png format (how many bits per pixel and there is alpha channel or not, may be palette or grayscale image). WHATWG spec also do not points this ie its UA dependent. Anyway basic rules:
+ browsers do not supports images with width or height > 20 000 px => we use square image instead linear(1*X or X*1)
+ if alpha component of canvas data eq 0 => browser reset red, green, blue to 0 too even if globalCompositeOperation = 'copy'
+ even if globalCompositeOperation = 'copy', globalAlpha = 1.0, dest alpha of pixel eq 255 - browser blends src image data when you perform putImageData and original red, green, blue components corrupts due floating point errors. For example we have one pixel [1,129,130,131], let see putImageData(this pixel); getImageData() -> [1,128,130,131]; drawImage(toDataUrl()); ; getImageData -> [1,126,128,131] =>