Skip to content

Instantly share code, notes, and snippets.

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

Alex piscis

🧱
¯\_(ツ)_/¯
View GitHub Profile
@piscis
piscis / Document.php
Created December 5, 2012 13:23 — forked from beberlei/Document.php
My Symfony2 File Upload workflow
<?php
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
/**
* @Entity
*/
class Document
{
@piscis
piscis / gist:4208931
Created December 4, 2012 21:32
IPV6 configuration UBUNTU 12.04
# The loopback network interface
auto lo eth0
iface lo inet loopback
iface eth0 inet dhcp
iface eth0 inet6 static
address 2a00:1158:X::XX #<- Your IPv6 Address
netmask 64 # <- No slashes
gateway fe80::1 #<- Gateway
@piscis
piscis / crc32-test.js
Created November 21, 2012 11:20
CRC32 Tests NodeJS/PHP
var crc32 = require('buffer-crc32'); // npm install buffer-crc32;
var crc = require('crc'); // npm install crc
var str = "Hello CRC";
var strUTF8= "<!DOCTYPE html>\n<html>\n<head>\n</head>\n<body><p>自動販売</p></body></html>";
var bufUTF8 = new Buffer(strUTF8);
var bufStr = new Buffer(str);
// Example 1
@piscis
piscis / License
Created November 19, 2012 13:19
Methods 0.0.1 License
## License
(The MIT License)
Copyright (c) 2011 TJ Holowaychuk &lt;[email protected]&gt;
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
@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"
},
@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 / 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: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 / 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: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){