Skip to content

Instantly share code, notes, and snippets.

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 March 22, 2014 15:54
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
// 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 January 6, 2016 18:00
Basic library and sample html page showing how to create a basic app for PHPFox
<?php
class FoxApp
{
private $_sFoxUrl = null;
private $_sAppId = null;
private $_sToken = null;
public function __construct($sFoxUrl = null, $sAppId = null)
{
@purefan
purefan / tree
Created April 27, 2013 15:29
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.
#!/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 #
ââ⬠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 April 17, 2013 08:31
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
#!/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 08:26
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
#!/bin/bash
find . -not -iwholename '*.svn*' -type f -print | xargs egrep --color=auto --line-number --no-messages "$1"