Skip to content

Instantly share code, notes, and snippets.

@ghoseb
ghoseb / factorial.py
Created November 14, 2008 18:58
The evolution of a Python Programmer
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@jfsiii
jfsiii / img2data.js
Created January 31, 2011 15:54
base64 encoding images in NodeJS
/*
* Complete reworking of JS from https://gist.github.com/803410
* Removes external `request` dependency
* Caveats:
* * No error checking
* * Largely a POC. `data` URI is accurate, but this code cannot simply be inserted into an `express` app
*/
var URL = require('url'),
sURL = 'http://nodejs.org/logo.png',
oURL = URL.parse(sURL),
@basham
basham / nodejs-rfid.js
Last active May 1, 2024 12:56
Use NodeJS to read RFID ids through the USB serial stream.
/*
DESCRIPTION
-----------
Use NodeJS to read RFID ids through the USB serial stream. Code derived from this forum:
http://groups.google.com/group/nodejs/browse_thread/thread/e2b071b6a70a6eb1/086ec7fcb5036699
CODE REPOSITORY
---------------
https://gist.github.com/806605
@strongwave
strongwave / getCurrentPosition_canvas.html
Created October 17, 2011 23:40
A Demo Drawing Google Map on Canvas Tag for HTML5
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script>
jQuery(window).ready(function(){
g_initialize();
jQuery("#findLocationBtn").click(initiate_geolocation);
});
@mattsahr
mattsahr / native.scroll.html
Created November 17, 2011 02:47
IOS Webkit - native internal scroll - a fix for the document page-top-bounce
<!DOCTYPE html>
<html>
<!-- NOTES
Demo - uses IOS native scroll available in IOS5, but sidestep the document-bounce behavior. Tested on iPad 1, using IOS 5.1.
This approach uses a set of 3 nested divs.
OuterDiv -- fixed height, width, overflow-scrolling: touch;
MiddleDiv -- fixed height width, overflow-scrolling: touch; fits inside OuterDiv
InnerDiv -- fixed height width, bigger than MiddleDiv, so it kicks in the overflow behavior
@quis
quis / imageProxy.php
Created March 16, 2012 10:47
Wordpress responsive image proxy
<?php
class ImageProxy {
function __construct($request) {
$this->sourceFolder = "/wp-content/uploads/";
$this->path = dirname($request);
$this->partialFileName = str_replace($this->path."/", "", $request);
@dearaujoj
dearaujoj / gist:2663082
Created May 11, 2012 23:29 — forked from anonymous/gist:2388015
iOS fix for iframe cropping
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
if (/iPhone|iPod|iPad/.test(navigator.userAgent))
$('iframe').wrap(function(){
var $this = $(this);
return $('<div />').css({
width: $this.attr('width'),
height: $this.attr('height'),
overflow: 'auto',
@dariocravero
dariocravero / README.md
Created October 20, 2012 05:25
Save files in Meteor

Create a Meteor app and put the client_/server_ files in a client/server directories. Also, create a public dir to save the uploaded files.

@cimmanon
cimmanon / flexbox.scss
Last active September 17, 2020 15:05 — forked from anonymous/Flexbox mixins
This collection of Sass mixins to cover all 3 flexbox specifications that have been implemented. More information can be found here: https://gist.github.com/cimmanon/727c9d558b374d27c5b6
@import "compass/css3/shared";
// NOTE:
// All mixins for the 2009 spec have been written assuming they'll be fed property values that
// correspond to the standard spec. Some mixins can be fed values from the 2009 spec, but don't
// rely on it. The `legacy-order` mixin will increment the value fed to it because the 2009
// `box-ordinal-group` property begins indexing at 1, while the modern `order` property begins
// indexing at 0.
// if `true`, the 2009 properties will be emitted as part of the normal mixin call
@zkenda
zkenda / JsLitmus.js
Last active December 12, 2015 02:58
My approach to less.modifyVars. To avoid reparsing I just modify "expression tree" and then render again. Only intresting file is less-1.3.1.modifyVars.js and perhaps modified less-1.3.1.js (which is actually 1.3.3). Index.html, test.less and jsLitmus.js are for demonstration.
// JSLitmus.js
//
// Copyright (c) 2010, Robert Kieffer, http://broofa.com
// Available under MIT license (http://en.wikipedia.org/wiki/MIT_License)
(function() {
// Private methods and state
// Get platform info but don't go crazy trying to recognize everything
// that's out there. This is just for the major platforms and OSes.