Skip to content

Instantly share code, notes, and snippets.

View jppommet's full-sized avatar
🏠
Working from home

Jean-Pierre Pommet jppommet

🏠
Working from home
View GitHub Profile
@jppommet
jppommet / int2ip.js
Last active December 26, 2023 13:44
javascript conversion from ip address to long integer and vice versa
function int2ip (ipInt) {
return ( (ipInt>>>24) +'.' + (ipInt>>16 & 255) +'.' + (ipInt>>8 & 255) +'.' + (ipInt & 255) );
}
// Lack of tail call optimization in JS
var sum = function(x, y) {
return y > 0 ? sum(x + 1, y - 1) :
y < 0 ? sum(x - 1, y + 1) :
x
}
sum(20, 100000) // => RangeError: Maximum call stack size exceeded
// Using workaround
@jppommet
jppommet / nodejs-crypto-sha1.js
Last active February 17, 2022 16:05
nodejs crypto sha1 hash in hexadecimal string representation.
// We use crypto.randomBytes(20) as an example to generate the seed with a higher entropy, higher number of unique values
var hash = crypto.createHash('sha1').update(crypto.randomBytes(20)).digest('hex')
@jppommet
jppommet / npm-update-S
Created August 4, 2013 21:02
Update all the saved dependencies defined in your package.json. Useful. This command is not documented curiously.
npm update -S
@jppommet
jppommet / py-virtualenv-project-cmds
Last active December 22, 2015 07:59
python virtualenv project shell commands
# init a python project
pip install virtualenv
virtualenv --distribute <venv_dirname>
source <venv_dirname>/bin/activate
# install dependencies
pip install -r requirements.txt
# exit virtualenv mode
deactivate
@jppommet
jppommet / ubuntu13.10-last-nvidia-drivers
Last active December 26, 2015 12:18
Install NVIDIA Drivers Last Stable Release (long-lived branch) for Ubuntu 13.10
1. Since we are using NVIDIA driver, we need to remove or disable XServer Nouveau Drivers
* Disable :
** sudo nano /etc/modprobe.d/blacklist-nouveau.conf
** Add the following two lines :
blacklist nouveau
options nouveau modeset=0
* Remove : sudo apt-get remove xserver-xorg-video-nouveau
2. Stop the display manager : sudo service lightdm stop
3. Install the drivers :
@jppommet
jppommet / nodejs-force-gc
Created October 28, 2013 21:06
Force node.js garbage collection
# cli
$ node --expose-gc test.js
# in .js source code
global.gc()
@jppommet
jppommet / lsb_release
Created November 5, 2013 15:08
Alternative uname -a, didn't know there was such a command line lol :)
$ lsb_release -a
@jppommet
jppommet / dart-ubuntu-13.10-issues
Created December 13, 2013 18:41
Dart Editor Issues on Linux Ubuntu 13.10
1. Menu do not display
* Type : $ nano .local/share/applications/dart_editor.desktop
* Make sure you have the following lines in this file :
Icon=<your_path>/dart/icon.xpm
Path=<your_path>/dart
Exec=env UBUNTU_MENUPROXY= <your_path>/dart/DartEditor (!! space character important here !!)
2. Dartium can not be open b/c libudev.so.0 was not found
@jppommet
jppommet / yo-generators-setup.md
Created February 17, 2014 21:29
List of yeoman generators that are very useful to scaffold front-end boilerplate code

Intro

Below a list of yeoman tools, generators that are very useful to scaffold front-end boilerplate code.

Also It can be very helpful in adding them into a docker container and share.

Generators

Envcheck makes sure that everything is installed properly in order to run yeoman smoothly

$ npm install -g envcheck