Skip to content

Instantly share code, notes, and snippets.

@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 / 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"');
mysqladmin -u<user> -p -i <interval> processlist
@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"' \;
> cat /dev/null > file
@cmpscabral
cmpscabral / gist:46deeb742e4d0e27a12c
Created January 27, 2015 18:26
mysql lock timeout
mysql> show open tables where in_use>0;
mysql> show processlist;
mysql> kill put_process_id_here;
mysql> show variables like 'innodb_lock_wait_timeout';
mysql> set innodb_lock_wait_timeout=100;
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
<?php
/**
* Batch Mockup
* Allows batch inserts
*
* I placed this in my BaseController.php
*
* Revision 0.2
*
* @usage
server {
client_max_body_size 20M;
listen 80;
server_name _; #make sure _ is replaced with your main domain if you plan on hosting multiple sites.
root /home/wordpress/wordpress; #You can also use /home/ubuntu/your_domain
#on server block
##necessary if using a multi-site plugin
server_name_in_redirect off;
##necessary if running Nginx behind a reverse-proxy
port_in_redirect off;
//
// Track.js - tracking scripts by alex miller
//
//
config = {};
config.track = true;// set to true in production, false in dev env
config.dump = true;// set to false in production env, true in dev
config.mixpanel = true; // <%= TRACKS_CONFIG['mixpanel'] %>; // set to true in production env, false in dev
config.googleAnaltyics = true;