Skip to content

Instantly share code, notes, and snippets.

View danielnaranjo's full-sized avatar

Daniel Naranjo danielnaranjo

View GitHub Profile
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active May 16, 2024 16:51
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@jakebellacera
jakebellacera / ICS.php
Last active June 2, 2024 02:20
A convenient script to generate iCalendar (.ics) files on the fly in PHP.
<?php
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
@jsjohnst
jsjohnst / example_output.png
Created May 13, 2011 17:10
Example of getting recommendations from LinkedIn JSAPI
example_output.png
@chluehr
chluehr / ipinfodb-jquery.html
Created July 14, 2011 09:20
Query ipinfodb via jquery / JSONP
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>
$.getJSON("http://api.ipinfodb.com/v3/ip-country/?key=API_KEY_HERE&format=json&callback=?",
function(data){
alert(data['countryCode']); //DE,AT ...
});
</script>
</head>
@jboner
jboner / latency.txt
Last active June 17, 2024 02:27
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@cherifGsoul
cherifGsoul / RestController.php
Last active November 1, 2018 13:54
Yii simple rest controller exemple
<?php
/**
* Controller is the customized base controller class.
* All controller classes for this application should extend from this base class.
*/
class RestController extends CController
{
/**
* @var string the default layout for the controller view. Defaults to '//layouts/column1',
* meaning using a single column layout. See 'protected/views/layouts/column1.php'.
@MoOx
MoOx / less2stylus.js
Created August 27, 2012 17:37 — forked from lancejpollard/less2stylus.coffee
Convert LESS to Stylus
// Usage : less2stylusDir('../src/css/');
var fs = require('fs');
// this less 2 stylus conversion script make a stylus easy to read syntax
// - let the braces
// - replace the @ for var as $
// - let semicolons
function less2stylus(less)
@sorah
sorah / a.js
Created September 9, 2012 07:30
listen to any events on socket.io / node EventEmitter; public domain own your risk
var SocketIO = require('socket.io')
, HTTP = require('http');
var orig_emit = SocketIO.Socket.prototype.$emit // http://nodejs.org/api/events.html#events_emitter_emit_event_arg1_arg2
SocketIO.Socket.prototype.$emit = function() {
orig_emit.apply(this, arguments)
var args = Array.prototype.slice.call(arguments);
var event = args.shift();
orig_emit.apply(this, ['anything', event, args]);
};
@kloon
kloon / gist:3972435
Created October 29, 2012 08:47
WooCommerce disable payment gateways based on customer country
// Disable gateway based on country
function payment_gateway_disable_country( $available_gateways ) {
global $woocommerce;
if ( isset( $available_gateways['ccavenue'] ) && $woocommerce->customer->get_country() <> 'IN' ) {
unset( $available_gateways['ccavenue'] );
} else if ( isset( $available_gateways['paypal'] ) && $woocommerce->customer->get_country() == 'IN' ) {
unset( $available_gateways['paypal'] );
}
return $available_gateways;
}
@cyberwombat
cyberwombat / CORS Configuration
Created November 1, 2012 19:18
JQuery file upload plugin (blueimp) with NodeJs Express3 directly to Amazon S3 with public access
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>