Skip to content

Instantly share code, notes, and snippets.

View eduardonunesp's full-sized avatar
🐚

Eduardo Pereira eduardonunesp

🐚
View GitHub Profile
@tobiash
tobiash / qredis.coffee
Created June 6, 2012 20:30
Q + node_redis
# Applies Q.nbind to all redis operations and returns a wrapped client
_ = require("underscore")._
Q = require "q"
nbindOps = (client) ->
functions = _.functions client
# All the ops are available as upper/lowercase functions, I exploit this
# to filter out the Redis operations from the other functions of the client
#
@dsibilly
dsibilly / gist:2992412
Created June 26, 2012 01:00
Node.js clustered HTTP server example
(function () {
'use strict';
var cluster = require('cluster'),
http = require('http'),
os = require('os'),
/*
* ClusterServer object
@4poc
4poc / gist:3155832
Created July 21, 2012 13:30
C++11 Callbacks with function and lambda
#include <iostream>
#include <vector>
#include <functional>
class WorkingClass {
public:
typedef const std::function<void (int)> handler_t;
void AddHandler(handler_t& h) {
handlerList.push_back(&h);
}
@duksis
duksis / .bash_profile
Created December 13, 2012 13:40
Default CentOS bash_profile and bashrc files
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
@yoggy
yoggy / uuid_test.c
Created January 8, 2013 11:19
libuuid sample program
//
// libuuid sample program
//
// library install for debian
// $ sudo apt-get install uuid-dev
//
// compile
// $ gcc uuid_test.c -luuid -o uuid_test
//
#include <stdio.h>
@zakhardage
zakhardage / Shopify Random Product Order
Last active February 23, 2023 07:47
Random Product Order in Shopify
<script type="text/javascript">
function fisherYates ( myArray ) {
var i = myArray.length, j, temp;
if ( i === 0 ) return false;
while ( --i ) {
j = Math.floor( Math.random() * ( i + 1 ) );
temp = myArray[i];
myArray[i] = myArray[j];
myArray[j] = temp;
}
@jonah-williams
jonah-williams / circle.yml
Last active May 29, 2019 14:53
Automating deployments to Heroku from CircleCI
test:
override:
- bundle exec rspec spec
deployment:
acceptance:
branch: master
commands:
- ./script/heroku_deploy.sh <ACCEPTANCE_HEROKU_APP>:
timeout: 300
@guptag
guptag / Q.js Examples
Last active April 4, 2021 06:22
Q.js examples - Small snippets to understand various api methods in Q.js
//To run Q.js examples:
// 1. Open a new browser tab in Chrome and turn on developer toolbar (or open any http site).
// 2. Copy/Paste this gist in the console and hit enter to run the snippets.
// Based on the inspiration from samples @ https://github.com/kriskowal/q
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
@johannes-weber
johannes-weber / ValidateFloat.js
Last active January 24, 2016 10:35
AngularJS Custom Float Validation
'use strict';
/**
* This directive parses both 1.2 and 1,2 into a valid float number 1.2.
* Note that you can't use input type number here as HTML5 browsers would
* not allow the user to type what it would consider an invalid number such as 1,2.
*
* <input ng-model="{yourModel}" validate-float />
*/
angular.module('Library').directive('validateFloat', function () {
package main
import (
"bufio"
"fmt"
"net"
)
type Client struct {
incoming chan string