Skip to content

Instantly share code, notes, and snippets.

@cmpscabral
cmpscabral / gist:3f05834ad2cff2e54488
Created March 16, 2015 16:53
search inside PDF's
find /path -name '*.pdf' -exec sh -c 'pdftotext "{}" - | grep --with-filename --label="{}" --color "your pattern"' \;
mysqladmin -u<user> -p -i <interval> processlist
@cmpscabral
cmpscabral / download.php
Last active April 11, 2021 22:39
on the fly zip stream download
<?php
//
// taken from http://stackoverflow.com/questions/4357073/on-the-fly-zipping-streaming-of-large-files-in-php-or-otherwise
//
// make sure to send all headers first
// Content-Type is the most important one (probably)
//
header('Content-Type: application/octet-stream');
header('Content-disposition: attachment; filename="file.zip"');
@cmpscabral
cmpscabral / mysqldump.sh
Created July 21, 2015 21:46
mysql dump to tar.gz
mysqldump mydatabase -u root -p | gzip -c | cat > mydatabase-$(date +%Y-%m-%d-%H.%M.%S).sql.gz
@cmpscabral
cmpscabral / removesvn.sh
Created July 21, 2015 22:25
remove svn files
find . -name .svn -print0 | xargs -0 rm -r
@cmpscabral
cmpscabral / open_files_processes.sh
Created July 27, 2015 23:36
open files/processes
watch -n 5 --differences “lsof -n -p 25894 | grep -v /home/lib/mysql”
@cmpscabral
cmpscabral / what-forces-layout.md
Created October 8, 2015 10:46 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
zip -r output.zip inputdir -x "**/.svn**"
@cmpscabral
cmpscabral / newmac.sh
Created November 27, 2015 15:44
new mac configuration file
#!/bin/sh
# _
# | |
# __ _____ ___ __| | ___
# \ \/ / __/ _ \ / _` |/ _ \
# > < (_| (_) | (_| | __/
# /_/\_\___\___/ \__,_|\___|
/Users/mg/Dropbox/mg/setup.sh
@cmpscabral
cmpscabral / mysql_dump_all.sh
Created December 29, 2015 19:13
dump and restore all databases
mysqldump -u root -p --opt --all-databases > alldb.sql
mysqldump -u root -p --all-databases --skip-lock-tables > alldb.sql