Skip to content

Instantly share code, notes, and snippets.

@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"
@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 / 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 #
@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 / 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
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 / gist:335626db8cf739c9cd08
Created September 24, 2014 06:57
Sublime natural tab order
Put in (Preferences -> Key Bindings - User):
{ "keys": ["ctrl+tab"], "command": "next_view" },
{ "keys": ["ctrl+shift+tab"], "command": "prev_view" }
Verifying that +purefan is my Bitcoin username. You can send me #bitcoin here: https://onename.io/purefan
@purefan
purefan / gist:b3e72ed6847edfcf7eaa
Created March 7, 2015 01:17
NullPointer Exception running build-deps.sh
[info] Set current project to tmp-6tdmfihlov (in build file:/tmp/tmp.6tdmfIhloV/)
[info] Packaging /tmp/tmp.6tdmfIhloV/target/scala-2.10/tmp-6tdmfihlov_2.10-0.1-SNAPSHOT-sources.jar ...
[info] Done packaging.
[info] Updating {file:/tmp/tmp.6tdmfIhloV/}tmp-6tdmfihlov...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Wrote /tmp/tmp.6tdmfIhloV/target/scala-2.10/tmp-6tdmfihlov_2.10-0.1-SNAPSHOT.pom
[info] :: delivering :: default#tmp-6tdmfihlov_2.10;0.1-SNAPSHOT :: 0.1-SNAPSHOT :: integration :: Sat Mar 07 01:14:23 UTC 2015
[info] delivering ivy file to /tmp/tmp.6tdmfIhloV/target/scala-2.10/ivy-0.1-SNAPSHOT.xml
[info] Packaging /tmp/tmp.6tdmfIhloV/target/scala-2.10/tmp-6tdmfihlov_2.10-0.1-SNAPSHOT-javadoc.jar ...