Skip to content

Instantly share code, notes, and snippets.

@soyuka
soyuka / upgradePrestashopPictures.php
Last active December 23, 2015 23:39
Prestashop images upgrade between < 1.4 (not 1.4) and 1.5, creates the folders according to the pictures names.
<?php
/**
* @author Antoine Bluchet
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@soyuka
soyuka / uri.js
Created October 1, 2013 07:06 — forked from jlong/uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@soyuka
soyuka / sockets.js
Created October 5, 2013 10:09
Handle sockets in a different file node.js with expressjs
/* app.js */
var server = http.createServer(app).listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});
var io = require('./utils/sockets').listen(server); //for example
/* utils/sockets.js */
var socketio = require('socket.io');
## The Problem
Standard practices say no non-root process gets to talk to the Internet on a port less than 1024. How, then, could I get Node talking on port 80 on EC2? (I wanted it to go as fast as possible and use the smallest possible share of my teeny tiny little micro-instance's resources, so proxying through nginx or Apache seemed suboptimal.)
## The temptingly easy but ultimately wrong solution:
Alter the port the script talks to from 8000 to 80:
}).listen(80);
@soyuka
soyuka / install.sh
Created October 16, 2013 13:17
Node.js and mongodb installation shell — Debian Wheezy
#!/bin/bash
# Adding mongodb source
apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen' | tee /etc/apt/sources.list.d/10gen.list
apt-get update
# Dependecies
# whois = mkpasswd

MacOS

Download from here:

http://d.pr/f/QE3d

MD5: 59bab8f71f8c096cd3f72cd73851515d

Rename it to:

@soyuka
soyuka / pm2-init.sh
Last active August 29, 2015 13:56
PM2 update-rc.d
#!/bin/bash
# chkconfig: 2345 98 02
#
# description: PM2 next gen process manager for Node.js
# processname: pm2
#
### BEGIN INIT INFO
# Provides: pm2
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
@soyuka
soyuka / gist:9296111
Created March 1, 2014 19:52
basic daemon.sh
d_start() {
}
d_stop() {
}
case "$1" in
@soyuka
soyuka / app.js
Created March 10, 2014 20:47
Angular js keeping the hash anchor navigation with html5mode router
app.config(function($stateProvider, $urlRouterProvider, $locationProvider) {
$locationProvider.hashPrefix('!').html5Mode(true)
})
app.run(function($rootScope, $location) {
$rootScope.$on('$locationChangeStart', function(e, next, current) {
//prevent first load
@soyuka
soyuka / index.js
Created March 24, 2014 22:41
Expressjs 4.0.0-rc3 - middlewares + sub router issue
process.env.DEBUG = '*'
var express = require('express')
var app = express()
var middleware = function(req, res, next) {
console.log('Trying to put a middleware here')
next(null)
},