Skip to content

Instantly share code, notes, and snippets.

View nicolascine's full-sized avatar
🎯
I may be slow to respond.

Nicolás Silva nicolascine

🎯
I may be slow to respond.
View GitHub Profile
@javiertapia
javiertapia / jquery.validate.rut.js
Created February 16, 2009 14:03
Validar rut mediante jQuery.Validate
function validaRut(campo){
if ( campo.length == 0 ){ return false; }
if ( campo.length < 8 ){ return false; }
campo = campo.replace('-','')
campo = campo.replace(/\./g,'')
var suma = 0;
var caracteres = "1234567890kK";
var contador = 0;
@cmichi
cmichi / jQuery-file-exists.js
Created November 30, 2010 22:56
Very simple way to check if a file exists, using jQuery.
/**
* Very simple way to check if a file exists on this domain.
* Use with the jQuery library.
*
* Important: Works only on the same domain.
* Cross-domain-requests have to be done in another way (see JSONP)!
*
* Use: console.log( "/data/list.json".fileExists() );
*/
String.prototype.fileExists = function() {
@adamloving
adamloving / fb-fan-export.js
Created January 18, 2011 01:02
Export Facebook Page Fans
/*
For more detailed instructions on how to use this script, sign up with your email here:
http://adamloving.com/internet-programming/how-toexport-facebook-page-fans
DISCLOSURE: This javascript runs in your browser pretending to be you
looking through your page fans. Facebook should have no problem with this,
but who knows if they will think it is strange to see you looking through
all your fans so quickly (the script waits 3s before requesting each page).
I've had no problem running this so far for 1000s of page fans, but I
@DanielG
DanielG / cors-proxy.js
Created April 2, 2011 22:39
cors proxy in nodejs
var http = require('http');
var connect = require('connect');
var httpProxy = require('http-proxy');
var proxy = module.exports = function(options){
return function (req, res) {
var proxy = new httpProxy.HttpProxy(req, res);
var headerFields = null;
@jimeh
jimeh / jquery.myplugin.coffee
Created April 7, 2011 23:44
Example jQuery plugin written in CoffeeScript, and the resulting compiled JavaScript file.
$.fn.extend
myplugin: (options) ->
self = $.fn.myplugin
opts = $.extend {}, self.default_options, options
$(this).each (i, el) ->
self.init el, opts
self.log el if opts.log
$.extend $.fn.myplugin,
default_options:
@hans
hans / zip.coffee
Created April 12, 2011 04:42
Haskell-esque `zip` and `zipWith`, ported to node.js / CoffeeScript
zip = (arr1, arr2) ->
basic_zip = (el1, el2) -> [el1, el2]
zip_with basic_zip, arr1, arr2
# I wrote two implementations of `zipWith`: one is iterative, and one is recursive. Feel free to do some benchmarks if you feel like it :)
# zip_with, iterative style
zip_with = (func, arr1, arr2) ->
min = Math.min arr1.length, arr2.length
ret = []
@kares
kares / jquery.parseparams.js
Created May 5, 2011 11:28
jQuery.parseParams - parse query string paramaters into an object
/**
* $.parseParams - parse query string paramaters into an object.
*/
(function($) {
var re = /([^&=]+)=?([^&]*)/g;
var decodeRE = /\+/g; // Regex for replacing addition symbol with a space
var decode = function (str) {return decodeURIComponent( str.replace(decodeRE, " ") );};
$.parseParams = function(query) {
var params = {}, e;
while ( e = re.exec(query) ) {
@jed
jed / LICENSE.txt
Created May 20, 2011 13:27 — forked from 140bytes/LICENSE.txt
generate random UUIDs
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
@mbostock
mbostock / .block
Last active April 23, 2024 12:30
Hierarchical Edge Bundling
license: gpl-3.0
height: 960
border: no
redirect: https://observablehq.com/@d3/hierarchical-edge-bundling
@nijikokun
nijikokun / sprintf.js
Created July 3, 2011 21:36
Sprintf / Format for Javascript (Java like / PHP like functionality)
/*
* "%s %s %s".format("Format", "For", "Javascript");
* Based on PHPJS sprintf.
*
* @author: Nijikokun <[email protected]>
* @copyright: 2011 (c) Nijikokun
*/
String.prototype.format=function(){var k=arguments,q=0,o=function(b,a,f,c){f||(f=" ");a=b.length>=a?"":Array(1+a-b.length>>>0).join(f);return c?b+a:a+b},m=function(b,a,f,c,g,d){var e=c-b.length;e>0&&(b=f||!g?o(b,c,d,f):b.slice(0,a.length)+o("",e,"0",!0)+b.slice(a.length));return b},n=function(b,a,f,c,g,d,e){b>>>=0;f=f&&b&&{2:"0b",8:"0",16:"0x"}[a]||"";b=f+o(b.toString(a),d||0,"0",!1);return m(b,f,c,g,e)};return this.replace(/%%|%(\d+\$)?([-+\'#0 ]*)(\*\d+\$|\*|\d+)?(\.(\*\d+\$|\*|\d+))?([scboxXuidfegEG])/g,
function(b,a,f,c,g,d,e){var i,j;if(b=="%%")return"%";var h=!1;j="";var l=g=!1;i=" ";for(var r=f.length,p=0;f&&p<r;p++)switch(f.charAt(p)){case " ":j=" ";break;case "+":j="+";break;case "-":h=!0;break;case "'":i=f.charAt(p+1);break;case "0":g=!0;break;case "#":l=!0}c=c?c=="*"?+k[q++]:c.charAt(0)=="*"?+k[c.slice(1,-1)]:+c:0;c<0&&(c=-c,h=!0);if