Skip to content

Instantly share code, notes, and snippets.

@lrhache
lrhache / heroku_stop_processes.md
Last active December 26, 2015 22:19
Command line helper to find and stop all manually initiated process on Heroku.

One of my automated process starts dynos when he feels he need more juice in the pipes. But, while running tests, something failed and just kept 10 or more dynos running. It's a pain to stop those manually.

Here's a simple command line that can be executed to stop all running dynos except those initiated at runtime or in via the Procfile.

heroku ps -a <HEROKU_APP> | grep -o -P '(run\.[0-9]+)' | while read line ; do heroku ps:stop $line -a <HEROKU_APP> ; done
@lrhache
lrhache / python-selenium-open-tab.md
Last active July 31, 2024 20:57
Python Selenium - Open new tab / focus tab / close tab

On a recent project, I ran into an issue with Python Selenium webdriver. There's no easy way to open a new tab, grab whatever you need and return to original window opener.

Here's a couple people who ran into the same complication:

So, after many minutes (read about an hour) of searching, I decided to do find a quick solution to this problem.

@lrhache
lrhache / heroku-set-configs-from-file.md
Created December 11, 2013 15:21
Easy way to batch set Heroku config from a file. No one wants to do this manually(!?).

#Heroku set configs from files

  • Export your configs from Heroku in "shell" format to file:

    $ heroku config -a <app_name> -s > .env-<environment_name(production, staging, ...)>
    
  • Copy this script to a file

@lrhache
lrhache / install
Last active August 29, 2015 13:57
neo4j install
mkdir ~/neo4j
mv neo4j-community-2.0.1-unix.tar.gz ~/neo4j/neo4j-community-2.0.1-unix.tar.gz
cd ~/neo4j
tar -xzf neo4j-community-2.0.1-unix.tar.gz
cp neo4j-community-2.0.1 <graph-name>
git clone git://github.com/neo4j/spatial.git spatial
cd spatial
mvn clean package -Dmaven.test.skip=true install
unzip target/neo4j-spatial-0.11-SNAPSHOT-server-plugin.zip -d ~/neo4j/<graph-name>/plugins/
~/neo4j/<graph-name>/bin/neo4j start
@lrhache
lrhache / install.sh
Last active August 29, 2015 13:58
PyQt in virtualenv
mkdir lib
cd lib
wget http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.10.4/PyQt-x11-gpl-4.10.4.tar.gz
tar xvf PyQt-x11-gpl-4.10.4.tar.gz
cd PyQt-x11-gpl-4.10.4/
python configure.py
make && make install
@lrhache
lrhache / install.sh
Created April 5, 2014 03:19
phantomjs
cd /usr/local/share
wget http://phantomjs.googlecode.com/files/phantomjs-1.9.7-linux-x86_64.tar.bz2
tar xjf phantomjs-1.9.7-linux-x86_64.tar.bz2
sudo ln -s /usr/local/share/phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/local/share/phantomjs
sudo ln -s /usr/local/share/phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs
sudo ln -s /usr/local/share/phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/bin/phantomjs
@lrhache
lrhache / list_unique_benchmark.py
Last active September 30, 2021 12:26
Two method to remove duplicates from a python list while keeping order
"""Benchmark multiple method of removing duplicates in a list
while keeping item's order in the list.
numpy.unique will likely be faster and more efficient
the more the list grows.
If a list is submitted to numpy.unique, it will be transformed and flattened
into a numpy.Array which it's data structure is more efficient than standard
lists since all elements have the same size in memory therefor requires less
access to the memory. Lists are stored as array of adresses pointing to
to the objects and requires more memory access (but more flexible).
@lrhache
lrhache / .bash_profile
Last active October 8, 2015 15:58
Install a new working environment
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
@lrhache
lrhache / export-mssql-csv.ps1
Last active March 11, 2024 20:06
Export all tables from a database to CSV files - AWS MSSQL 2008 / Win 2008
set-alias installutil $env:windir\microsoft.net\framework\v2.0.50727\installutil
installutil -i "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\Redist\Microsoft.SqlServer.Management.PSProvider.dll"
installutil -i "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\Redist\Microsoft.SqlServer.Management.PSSnapins.dll"
Add-PSSnapin SqlServerCmdletSnapin100
Add-PSSnapin SqlServerProviderSnapin100
$SERVER_NAME="<SERVER NAME>"; $DB_NAME="<DB NAME>";$Tables = invoke-sqlcmd -query "SELECT name FROM sys.tables order by name" -database $DB_NAME -serverinstance $SERVER_NAME;foreach ($Table in $Tables){$TableName = $Table["name"];write-host -ForegroundColor Green "Creating File $TableName.csv";invoke-sqlcmd -query "SELECT * FROM $TableName" -database $DB_NAME -serverinstance $SERVER_NAME |export-csv -path D:\dump\$TableName.csv;}
@lrhache
lrhache / bash
Created April 15, 2015 02:39
Set MySQL to EBS storage
sudo service mysql stop
sudo mkdir /ebs1/etc /ebs1/lib /ebs1/log
sudo mv /etc/mysql /ebs1/etc
sudo mv /var/lib/mysql /ebs1/lib
sudo mv /var/log/mysql /ebs1/log
sudo mkdir /etc/mysql /var/lib/mysql /var/log/mysql
echo "/ebs1/etc/mysql /etc/mysql none bind" | sudo tee -a /etc/fstab
sudo mount /etc/mysql
echo "/ebs1/lib/mysql /var/lib/mysql none bind" | sudo tee -a /etc/fstab
sudo mount /var/lib/mysql