Skip to content

Instantly share code, notes, and snippets.

@asiletto
asiletto / nodejs-mongohq.js
Created October 3, 2012 11:33
node.js connection to mongohq with node-mongodb-native and connection pooling
var dbHostname = 'xxxx.mongohq.com';
var dbPort = 10000;
var dbUsername = 'yyyy';
var dbPassword = 'zzzz';
var dbName = 'dddd';
var db = new mongodb.Db(dbName, new mongodb.Server(dbHostname, dbPort, {auto_reconnect: true, poolSize: 8}), {native_parser: false});
db.open(function(err, db) {
if(err) throw err;
@asiletto
asiletto / squid access.log big files
Created October 19, 2012 09:53
squid access.log big files
# cat access.log|awk -F" " '{requests[$7]=$5} END{for(url in requests) print requests[url] " " url }' |sort -n -r |head -n 100
@asiletto
asiletto / apache2.conf
Created November 22, 2012 09:50
apache2 configuration on amazon ec2 micro instance
<IfModule mpm_prefork_module>
MaxClients 10
</IfModule>
<IfModule mpm_worker_module>
MaxClients 10
</IfModule>
<IfModule mpm_event_module>
MaxClients 10
@asiletto
asiletto / gist:4731339
Created February 7, 2013 14:44
git commands
#clone a github repo
git clone https://github.com/user/repo.git
#commit & push
git commit -a
git push origin master
#tag version
git tag -a v1.0.0 -m "first version"
git push --tags
@asiletto
asiletto / gist:6291701
Created August 21, 2013 08:19
capture packets with windump/tcpdump
WinDump.exe -A -i 1 -n -q -U -s 0 -w file.dump host host.to.intercept
-A
Print each packet (minus its link level header) in ASCII.
-i 1
Listen on interface.
-n
Don't convert addresses (i.e., host addresses, port numbers, etc.) to names.
@asiletto
asiletto / ffmpeg_static_image
Last active December 21, 2015 12:19
video from static image with ffmpeg
ffmpeg.exe -loop 1 -i image.png -t 10 -vcodec libx264 sub.avi
@asiletto
asiletto / TestLog.java
Created August 23, 2013 09:19
Log4J JDBC appender test
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.MDC;
public class TestLog {
public static Log log = LogFactory.getLog(TestLog.class);
public static void main(String[] args) throws Exception {
@asiletto
asiletto / phpbb3sso.module
Created September 26, 2013 15:33
single sign on from phpbb3 to drupal using the forum session cookie.
<?php
define('PHPBB_SESSION_KEY', 'phpbb3_xxxxx_sid');
/**
* Implementation of hook_help().
*/
function phpbb3sso_help($path, $args) {
if ($path == 'admin/help#phpbb3sso') {
return t('This module enable SSO with a phpbb3 forum');
console.log('Hello world!');
@asiletto
asiletto / h1.sh
Last active January 4, 2016 08:19
$ node hello.js
Hello world!