Skip to content

Instantly share code, notes, and snippets.

View FLasH3r's full-sized avatar
💡
converting ideas to code

Roni Nes FLasH3r

💡
converting ideas to code
View GitHub Profile
@rixth
rixth / gist:1088478
Created July 18, 2011 03:15
jquery bookmarklet
/**
* This is a template bookmarklet that loads jQuery. Also works
* if another library has defined $ itself.
*/
(function () {
var s = document.createElement('script');
s.setAttribute('src', 'http://jquery.com/src/jquery-latest.js');
s.onload = function () {
jQuery.noConflict();
@geuis
geuis / whenthen.js
Created July 30, 2011 04:40
When-Then (pseudo javascript Promise)
var when = function(){
if( !(this instanceof when) ) return new when(arguments); //return new instance of itself
var self = this; //cached so the syntax of code within the function is more readable
self.pending = Array.prototype.slice.call(arguments[0]); //convert arguments passed in to array
self.pending_length = self.pending.length; //cache length of the arguments array
self.results = []; //container for results of async functions
(function(){ // define pass() within this context so that the outer scope of self(this) is available when pass() is executed within the user's async functions
@ktomk
ktomk / valid_utf8_bytes.php
Created October 4, 2011 19:10
filter valid utf-8 byte sequences
<?php
/**
* filter valid utf-8 byte sequences
*
* take over all valid bytes, drop an invalid sequence until first
* non-matching byte, start over at that byte.
*
* @param string $str
* @return string
*/
@leecade
leecade / LICENSE.txt
Created October 8, 2011 14:21 — forked from jed/LICENSE.txt
map properties for arrays and objects
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
@troelskn
troelskn / gist:1287893
Created October 14, 2011 18:24
Luhn's algorithm in php
<?php
function is_valid_luhn($number) {
settype($number, 'string');
$sumTable = array(
array(0,1,2,3,4,5,6,7,8,9),
array(0,2,4,6,8,1,3,5,7,9));
$sum = 0;
$flip = 0;
for ($i = strlen($number) - 1; $i >= 0; $i--) {
$sum += $sumTable[$flip++ & 0x1][$number[$i]];
@paulirish
paulirish / rAF.js
Last active March 22, 2024 00:00
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@jxson
jxson / README.md
Created February 10, 2012 00:18
README.md template

Synopsis

At the top of the file there should be a short introduction and/ or overview that explains what the project is. This description should match descriptions added for package managers (Gemspec, package.json, etc.)

Code Example

Show what the library does as concisely as possible, developers should be able to figure out how your project solves their problem by looking at the code example. Make sure the API you are showing off is obvious, and that your code is short and concise.

Motivation

@geuis
geuis / remote-typeahead.js
Created February 16, 2012 22:58
Remote data querying for Twitter Bootstrap 2.0 Typeahead without modifications
<script>
// Charles Lawrence - Feb 16, 2012. Free to use and modify. Please attribute back to @geuis if you find this useful
// Twitter Bootstrap Typeahead doesn't support remote data querying. This is an expected feature in the future. In the meantime, others have submitted patches to the core bootstrap component that allow it.
// The following will allow remote autocompletes *without* modifying any officially released core code.
// If others find ways to improve this, please share.
var autocomplete = $('#searchinput').typeahead()
.on('keyup', function(ev){
ev.stopPropagation();
@zhephree
zhephree / framed.html
Created February 17, 2012 19:02
Cross-domain Self-resizing IFRAME
<html>
<head></head>
<body onload="iframeResizePipe()">
<iframe id="helpframe" src='' height='0' width='0' frameborder='0'></iframe>
<script type="text/javascript">
function iframeResizePipe()
{
// What's the page height?
var height = document.body.scrollHeight;
@leecade
leecade / clearfix.css
Created March 9, 2012 08:33
css:clearfix
.clearfix{ zoom: 1;}
.clearfix:before, .clearfix:after{ content: ""; display: table;}
.clearfix:after { clear: both;}