Skip to content

Instantly share code, notes, and snippets.

@cdolek
cdolek / gist:1eaaf2d66e6b10230348e5db8b7fb60b
Last active October 27, 2016 15:47
Installing MySQL 5.6 on Debian Jessie
http://www.debiantutorials.com/install-mysql-server-5-6-debian-7-8/
# check if newer exists at: http://dev.mysql.com/downloads/repo/apt/
wget http://dev.mysql.com/get/mysql-apt-config_0.8.0-1_all.deb
dpkg -i mysql-apt-config_0.8.0-1_all.deb
@cdolek
cdolek / mongo-dump-csv.sh
Created December 17, 2016 17:23 — forked from mderazon/mongo-dump-csv.sh
Export all of Mongodb collections as csv without the need to specify fields
OIFS=$IFS;
IFS=",";
# fill in your details here
dbname=DBNAME
user=USERNAME
pass=PASSWORD
host=HOSTNAME:PORT
# first get all collections in the database
@cdolek
cdolek / gist:41ec1ca8c41ba797ec12b88c37718612
Created December 22, 2016 13:37 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@cdolek
cdolek / gist:bc0b39e19f7788a84ad9eb7f8ea10c8d
Created April 7, 2017 17:41 — forked from nilesolutions/gist:d1baa681afcfe14b7e24c23616f9147c
OS X 10.10 Yosemite Local Development Environment: Apache, PHP, and MySQL with Homebrew
Homebrew Setup
If you've not already installed Homebrew, you can follow the instructions at http://brew.sh. I used to include the command in previous walkthrough blogs, but it could change after posting, so definitely check their website to install it properly.
If you do not have git available on your system, either from Homebrew, Xcode, or another source, you can install it with Homebrew now (if you already have it installed, feel free to skip this step to keep the version of git you already have):
brew install -v git
PATH Variable
In previous guides on 10.9 and earlier, I added a change to $PATH in ~/.bash_profile to ensure that Homebrew-installed applications would run by default over similar ones that were already installed on OS X. Thankfully, Yosemite's $PATH order is different than earlier OS versions and now includes the default Homebrew location of /usr/local/bin in front. If you installed Homebrew to a custom location, or are not seeing /usr/local/bin at the beginning of your shell's $PATH, chec
@cdolek
cdolek / gist:b913c6936b1bd539d9f05ef1d9c2b9f6
Created May 31, 2017 23:26
Move first 1000 files in a folder to another folder
find . -maxdepth 1 -type f|head -1000|xargs -I{} mv {} ./targetDirectory
@cdolek
cdolek / gist:5670945111115fedb7ae420b4dcd8757
Last active June 2, 2017 20:43
Shell - get nth column of a csv file
# Get 2nd column of a csv file
awk -F "\"*,\"*" '{print $2}' sourceFile.csv > targetFile.csv
# Or
awk -F "," '{print $1}' someOtherSourceFile.csv > new.csv
@cdolek
cdolek / gist:c932ee612bc1967b42ea51ce10f42b83
Created June 2, 2017 18:26
Add string to every line of a CSV file
while IFS= read -r line; do echo "$line,string_I_would_like_to_add,some_other_string"; done < file
@cdolek
cdolek / gist:2d3f9faa6a98f823579ec8b6c0766a76
Last active June 5, 2017 22:15
Get n rows from a text file
# From 2 to 4
sed '2,4!d' somefile.txt
@cdolek
cdolek / gist:63ddb3711264ad602368baaa306906a0
Created June 2, 2017 20:49
Remove first and last character from csv
rev input.csv | cut -c2- | rev | cut -c2-
Or
sed 's/.$//; s/^.//' input.csv
@cdolek
cdolek / gist:27d180a2523a122e573c08e27953531e
Created June 3, 2017 00:09
Convert all lines in a csv to lowercase
cat file.csv | awk '{print tolower($0)}' > file_lowercase.csv