Skip to content

Instantly share code, notes, and snippets.

@lrhache
lrhache / bash
Created April 15, 2015 02:57
Load up multiple .sql dump files into MySQL
find . -name '*.sql' | awk '{ print "source",$0 }' | mysql --batch -u xxx -p <database>
@lrhache
lrhache / bash.sh
Created April 15, 2015 13:59
MySQL import from CSV files
mysqlimport -u root -p<password or prompt> -f --local <database> `pwd`/*.csv &> ../db_insert.log
@lrhache
lrhache / match-doublequote-enclosed.awk
Created April 21, 2015 01:05
Get text in enclosed in double quote
awk -F\" '{print $(NF-1)}'
@lrhache
lrhache / file-extension.awk
Created April 21, 2015 01:06
Find unique file extension from list of files
awk -F. '!a[$NF]++{print $NF}'
@lrhache
lrhache / missing-lines.sh
Last active August 29, 2015 14:19
Find all the missing lines from file B that are in file A
grep -F -x -v -f <file to compare:file B>.txt <base file:file A>.txt
# or:
comm <(sort fileB) <(sort fileA) -3 > output.txt
# prints lines that are both in file1 and file2 (intersection)
awk 'NR==FNR{a[$0];next} $0 in a' file1 file2
@lrhache
lrhache / ElasticSearch.sh
Last active September 2, 2015 13:22 — forked from ricardo-rossi/ElasticSearch.sh
Installing ElasticSearch on Ubuntu 14.04
#!/bin/bash
### USAGE
###
### ./ElasticSearch.sh 1.7 will install Elasticsearch 1.7
### ./ElasticSearch.sh will fail because no version was specified (exit code 1)
###
### CLI options Contributed by @janpieper
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch
@lrhache
lrhache / bitweekdays.py
Created January 8, 2016 15:37
Convert weekdays as bit representation
weekdays = ('Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday', 'Saturday', 'Sunday', )
def convert_choice(*args):
"""Convert weekdays representation to 127 bits
Example:
>> # Monday, Tuesday, Friday, Sunday
>> bw.convert(1, 1, 0, 0, 1, 0, 1)
@lrhache
lrhache / neo-geo.py
Last active January 26, 2016 19:07
Neo4j geospatial python
import time
import random
import requests
from profilehooks import profile
def timeit(method):
def timed(*args, **kw):
ts = time.time()
@lrhache
lrhache / neo4j-install-ubuntu.sh
Last active March 6, 2018 02:17
neo4j util script
#!/bin/sh
sudo echo "export NEO4J_HOME=/opt/neo4j" >> /etc/environment
source /etc/environment
sudo mkdir -p $NEO4J_HOME
sudo chown ubuntu.ubuntu $NEO4J_HOME
cd /tmp
@lrhache
lrhache / force-oauth.py
Created March 31, 2016 14:51
Another simple Python example with a real OAuth flow. This uses responses and the simple-salesforce lib
#!/usr/bin/python
import cgi
import requests
import json
from simple_salesforce import Salesforce
#login here:
#https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=3MVG9A2kN3Bn17hsWsLDatw._IVMEUBoPKv.7ksp0tz7xLX4tWDVgyzwTCA7i_yTfP.qYuNOsSoPNcdVH6DuE&redirect_uri=http://localhost/cgi-bin/python/oauth.py