Skip to content

Instantly share code, notes, and snippets.

@toretto460
toretto460 / gist:2851668
Created June 1, 2012 12:10
AB (Apache Benchmark) on Node.js server
$ ab -n 10000 -c 1000 http://localhost:5000/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
#Stop mysql service
service mysql stop
# Crate your ramdisk partition
mkdir /mnt/myramdisk
mount -t tmpfs -o size=150M tmpfs /mnt/myramdisk
# Set the correct permissions
chown mysql /mnt/myramdisk
chgrp mysql /mnt/myramdisk
@toretto460
toretto460 / gist:5966281
Last active December 19, 2015 13:59
Symfony2 virtualhost
<VirtualHost *:80>
DocumentRoot /path/to/symfony/web
ServerName booking.local
<Directory /path/to/symfony/web >
Options FollowSymLinks
AllowOverride All
Allow from all
@toretto460
toretto460 / SML_examples.sml
Last active December 27, 2015 04:39
Standard ML Examples
(* Type checker *)
fun fReal (x) = x + 0.0;
fun fInteger (x) = x + 0;
(*
if true then fReal(3.0) else fInteger(3);
Error: types of if branches do not agree !!
*)
(* call by value *)
fun myif a b c = if a then b else c;
@toretto460
toretto460 / natural.sml
Last active January 4, 2016 00:39
Natural numbers
abstype natural = next of natural | zero of unit
with
fun sum (zero(), n) = n
| sum (next(n), m) = next(sum(m ,n));
fun prod(zero(), n) = zero()
| prod(next(n),m) = sum(prod(n,m), m);
fun fact(zero()) = next(zero())
| fact(next(zero())) = fact(zero())
@toretto460
toretto460 / superminimal.js
Last active August 29, 2015 14:01
superminimal javascript templating
String.prototype.render = function(data){
return this.replace(
/\{([^{}]*)\}/g,
function(match, group){
var value = data[group];
if( typeof value === 'function' ) {
return value.apply(data);
} else if(typeof value === 'number' || typeof value === 'string') {
@toretto460
toretto460 / FraiolController.php
Last active August 29, 2015 14:03
A brand new implementatio of "Front Controller" Design Pattern
<?php
use Symfony\Component\HttpFoundation\Request;
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/AppKernel.php';
$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
@toretto460
toretto460 / PandocConverter.py
Created September 7, 2014 16:03
Convert files with pandoc from a format to another
from subprocess import call
import os
class PandocConverter:
def __init__(self, destination = 'dist', enableLogger = True):
self.commandBase = ['pandoc']
self.destination = destination
self.isLoggerEnabled = enableLogger
@toretto460
toretto460 / reduce_spec.md
Last active August 29, 2015 14:15
Reduce

#Basic: Recursion

Recursion is a fundamental programming concept which can lead to elegant and efficient solutions to algorithmic problems. In fact, recursion is so powerful, all iterating behaviour can be defined using recursive functions. You will find recursion indispensable when iterating over nested data structures.

A recursive function is a function which calls itself. For example, this recursive function will take an array of words, and return an array of those words, uppercased.

function toUpperArray(items) {
   if (!items.length) return []             // end condition
   var head = items[0]                      // item to operate on

head = head.toUpperCase() // perform action

@toretto460
toretto460 / docker-machine create
Last active November 4, 2015 10:42
/var/log/vnetlib errors
$ docker-machine -D create -d vmwarefusion fusion
Creating SSH key...
Creating VM...
Creating disk '/Users/toretto/.docker/machine/machines/fusion/fusion.vmdk'
Virtual disk creation successful.
Starting fusion...
executing: /Applications/VMware Fusion.app/Contents/Library/vmrun start /Users/toretto/.docker/machine/machines/fusion/fusion.vmx nogui
Waiting for VM to come online...
MAC address in VMX: 00:0c:29:7f:47:32
IP found in DHCP lease table: 192.168.2.129