Skip to content

Instantly share code, notes, and snippets.

Miguel Espinoza purefan

Block or report user

Report or block purefan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View front end pretty log
var log=function(){for(var a in arguments)if(0==a){if(-1<arguments[a].indexOf("::")&&(arguments[0]="[ "+arguments[a]+" ]"),arguments[0]!=this.logLastCalled){var b="%c "+Array(20).join(" ")+arguments[a]+Array(40-arguments[a].length).join(" "),c="background: #222;color: #bada55;";-1<arguments[0].indexOf("Error ")&&(b=b.replace("Error ",""),c="background: #222; color: #FF0000;");console.log(b,c)}}else"string"==typeof arguments[a]&&-1<arguments[a].indexOf("Yellow:")?console.log("%c "+arguments[a].replace("Yellow:",""),"background: #222, color: #FFFD40;"):console.log(arguments[a]);this.logLastCalled=arguments[0]};
@purefan
purefan / socket.io listen to http
Created Mar 22, 2014
Quick reminder of how to make socket.io listen to an http server. Most examples online that I have found use Express which is ok, but for a small thing might be an overkill
View socket.io listen to http
// This is how we can make a socket.io server listen to an http connection
var http = require('http');
var socket = require('socket.io');
// Im not sure if the order is important
http.createServer(function(req,res){
// handle requests to your http server
});
// we tell socket.io to listen to the http node
@purefan
purefan / app.class.php
Last active Jan 6, 2016
Basic library and sample html page showing how to create a basic app for PHPFox
View app.class.php
<?php
class FoxApp
{
private $_sFoxUrl = null;
private $_sAppId = null;
private $_sToken = null;
public function __construct($sFoxUrl = null, $sAppId = null)
{
@purefan
purefan / tree
Created Apr 27, 2013
Display folders in linux as tree. A script in bash provided by http://www.centerkey.com/tree/ No copyright infringement inteded, I couldn't find a license in the site. Pasted here just in case.
View tree
#!/bin/sh
#######################################################
# UNIX TREE #
# Version: 2.3 #
# File: ~/apps/tree/tree.sh #
# #
# Displays Structure of Directory Hierarchy #
# ------------------------------------------------- #
# This tiny script uses "ls", "grep", and "sed" #
# in a single command to show the nesting of #
View gist:5473424
ââ⬠cli-color@0.2.2
â âââ es5-ext@0.9.2
â ââ⬠memoizee@0.2.4
â âââ event-emitter@0.2.1
â âââ next-tick@0.1.0
ââ⬠engine.io@0.5.0
â âââ base64id@0.1.0
â âââ debug@0.6.0
â âââ engine.io-parser@0.3.0
â ââ⬠ws@0.4.25
@purefan
purefan / loading_time
Created Apr 17, 2013
Small script to measure loading times, stores loading times in format: real 0m1.468s user 0m0.000s sys 0m0.008s repeatedly so another script or an improved version of this one would be needed to parse averages and whatnot
View loading_time
#!/bin/bash
for i in {1..200}
do
echo "Run $i"
(time curl -silent -L "http://server" -output /dev/null) > /dev/null 2>> "bench.log"
done
@purefan
purefan / fif
Last active May 15, 2018
This is what I use to have a pretty "Search in files". In debian based distros you can add it to /usr/bin/fif and call it like this: fif whatever
View fif
#!/bin/bash
find . -not -iwholename '*.svn*' -type f -print | xargs egrep --color=auto --line-number --no-messages "$1"
You can’t perform that action at this time.