Skip to content

Instantly share code, notes, and snippets.

View tlenss's full-sized avatar
🏖️
Coding...

Thijs Lensselink tlenss

🏖️
Coding...
View GitHub Profile
@tlenss
tlenss / composer.json
Created August 8, 2017 21:43 — forked from Glutnix/composer.json
Checking PSR-2 validation with PHPCS using a pre-commit git hook.
{
"require-dev": {
"squizlabs/php_codesniffer": "2.0.*@dev"
},
"scripts": {
"post-install-cmd": [
"bash contrib/setup.sh"
]
}
}
c_red='\[\e[31m\]'
c_bold_red='\[\e[31;1m\]'
c_white='\[\e[37m\]'
c_bold_white='\[\e[37;1m\]'
c_green='\[\e[32m\]'
c_bold_green='\[\e[32;1m\]'
c_lblue='\[\e[1;34m\]'
c_bold_lblue='\[\e[1;34;1m\]'
c_cyan='\[\e[36m\]'
c_bold_cyan='\[\e[36;1m\]'
@tlenss
tlenss / remove_empty_lines.sh
Created January 14, 2015 10:35
Remove empty lines
sed '/^$/d' myFile > tt
curl -X POST -d `cat file.xml` http://some.url
@tlenss
tlenss / searchReplaceXargsSed
Last active August 29, 2015 14:05
find replace xargs & sed
find . -name '*.ini' -type f -print0 | xargs -0 sed -i 's|oldstring|newstring|g'
#!/bin/bash
if [ "$1" == "" ]; then
echo Usage: $0 pngfile
exit 0;
fi
FILE=`basename $1 .png`
if [ ! -e $FILE.png ]; then
@tlenss
tlenss / findlastchanged
Last active August 29, 2015 14:01
Find last changed file
find . -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "
@tlenss
tlenss / PS1
Last active August 29, 2015 14:00
$PS1
PS1="\n\[\e[31;1m\]\u\[\e[31;1m\]\[\e[37;1m\]@\[\e[37;1m\]\[\e[36;1m\]\h\[\e[36;1m\] \[\e[34;1m\]\A \[\e[30;1m\]\[\e[37;1m\]\w \n\[\e[32;1m\]\$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g') files, \$(/bin/ls -lah | /bin/grep -m 1 total | /bin/sed 's/total //')b \[\e[37;1m\]$ \[\e[0m\]"
@tlenss
tlenss / gist:7887909
Last active December 30, 2015 21:29
MySQL CSV export/import
Import CSV:
$ mysqlimport --fields-optionally-enclosed-by='"' --fields-terminated-by="," --lines-terminated-by="\n" --user=root --password database_name output.csv
(load data local infile 'output.csv' into table mt fields terminated by ',' optionally enclosed by '"' ignore 1 lines;)
Export CSV:
Might need to set the file privilege first (GRANT FILE ON *.* TO 'root'@'%';)
$ chmod 777 -R /tmp/foo
mysqldump -uroot -p -t -T/tmp/foo database_name table_name --fields-optionally-enclosed-by='"' --fields-terminated-by="," --lines-terminated-by="\n"
@tlenss
tlenss / gist:7887785
Created December 10, 2013 09:11
Find images in files
<?php
$path = "/path/to/images";
$ritit = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::CHILD_FIRST);
$r = array();
foreach ($ritit as $splFileInfo)
{
$output = $error = array();
if ($splFileInfo->getFilename() != '.' && $splFileInfo->getFilename() != '..')
{