Skip to content

Instantly share code, notes, and snippets.

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

Alex piscis

🧱
¯\_(ツ)_/¯
View GitHub Profile
@piscis
piscis / License
Created November 19, 2012 13:19
Methods 0.0.1 License
## License
(The MIT License)
Copyright (c) 2011 TJ Holowaychuk <[email protected]>
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 / 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 / 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 / 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:4247496
Created December 9, 2012 23:30
Basic Doctrine2 GridFS example
/** @Document */
Class Image
{
/** @Id */
private $id;
/** @Field */
private $name;
/** @File */
@piscis
piscis / gist:4318396
Created December 17, 2012 13:48
Little reminder about REST :-D
Create -> Post
Read -> Get
Update -> Put
Delete -> Delete
@piscis
piscis / gist:4705921
Last active December 12, 2015 03:18
Power to the closures!
var a = []; for(var i=1; i<=100;i++) a.push((i*1));
var stopWordAnalyzer = function(list){
return function(stopword){
var fizzCount = 0;
list.forEach(function(y){ if(stopword==y){fizzCount++;}});
console.log('There are: '+fizzCount+' '+stopword+' in 1..100');
}
}
@piscis
piscis / iptables_rules.sh
Created February 26, 2013 14:41
Its a start :-)
# Allow outgoing traffic and disallow any passthroughs
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
# Allow traffic already established to continue
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow ssh, web services
iptables -A INPUT -p tcp --dport ssh -j ACCEPT
@piscis
piscis / Find all versions of a formula
Last active December 15, 2015 12:49
Find all available versions of a homebrew formula and resove "fatal: '/usr/local/Library/Formula/XXX.rb' is outside repository" error
# Allways a good idea to sync with the formular repository first
alex$ brew update
# List available version
alex$ brew versions zmq
3.2.2 git checkout ab8de4b /usr/local/Library/Formula/zeromq.rb
2.2.0 git checkout 6a2e6ef /usr/local/Library/Formula/zeromq.rb
2.1.11 git checkout 497b13a /usr/local/Library/Formula/zeromq.rb
2.1.10 git checkout 4c8ed3a /usr/local/Library/Formula/zeromq.rb
2.1.9 git checkout 381c97f /usr/local/Library/Formula/zeromq.rb
@piscis
piscis / server.js
Last active December 15, 2015 19:28
Copy&Paste static file server with nodejs
/**
* Create a static file server
* requires: node-static
* example: npm install node-static
*/
var conf = {
port: 8080,
address: "0.0.0.0",
pubDir: __dirname,
options: {