Skip to content

Instantly share code, notes, and snippets.

View piscis's full-sized avatar
🧱
¯\_(ツ)_/¯

Alex piscis

🧱
¯\_(ツ)_/¯
View GitHub Profile
@piscis
piscis / proccess binding
Created December 15, 2011 15:51
Writing A Async Module +0.5.3
#include <v8.h>
#include <node.h>
#include <stdlib.h>
#include <errno.h>
using namespace node;
using namespace v8;
struct Test_req
{
@piscis
piscis / gist:1486675
Created December 16, 2011 16:17
Removes a class from html tag via javascript, this is usefull if you enhance user experiance via JS
<script type="text/javascript">
/* CSS to JS style detector */
document.getElementsByTagName("html")[0].className = document.getElementsByTagName("html")[0].className.replace( /(?:^|\s)no\-js(?!\S)/ , '' )
</script>
@piscis
piscis / Test drive
Created December 21, 2011 09:54
Parallel & serial directory walker
walk(process.env.HOME, function(err, results) {
if (err) throw err;
console.log(results);
});
@piscis
piscis / gist:1779908
Created February 9, 2012 13:24
Prototype inheritance example
var util = require("util");
var A =function() {
// constructor
}
A.prototype.on = function() {
console.log('Call A: ON');
};
@piscis
piscis / gist:1883583
Created February 22, 2012 09:27
Iphone like shortening function to short Text
var longText = "Super Duper Long Description from the manual for the dashboard";
var shortText = "Main Screen";
var shortTxt = function(txt,max,fill) {
var sTxt = txt,
max = max || 12,
fill = fill || '...';
if(txt.length>=max){
@piscis
piscis / gist:1986678
Created March 6, 2012 14:56
JSON Sort
function sortObject(o) {
var sorted = {},
key, a = [];
for (key in o) {
if (o.hasOwnProperty(key)) {
a.push(key);
}
}
@piscis
piscis / gist:3168632
Created July 24, 2012 07:44 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@piscis
piscis / logtest.js
Created September 6, 2012 08:28
Formats a logfile with json objects seperated by linebreaks and prettyfies it
/**
* npm install carrier
* npm install parser
* tail -f /tmp/json.log | node logtest.js
*
* Logfile example:
* {"level":"info","message":"beep boop"}
* {"level":"error","message":"foo bar"}
*/
@piscis
piscis / gist:3839018
Created October 5, 2012 09:54
Create a fullscreen window
var appjs = require('appjs');
// serve static files from a directory
appjs.serveFilesFrom(__dirname + '/content');
// handle requests from the browser
appjs.router.post('/', function(request, response, next){
response.send('Hey! How are you ' + request.post('firstname'));
})
@piscis
piscis / gist:4110297
Created November 19, 2012 11:58
Dependencies
{
"name": "XXX",
"version": "0.0.1",
"dependencies": {
"argparser": {
"version": "0.2.1"
},
"async": {
"version": "0.1.22"
},