Skip to content

Instantly share code, notes, and snippets.

@cdolek
cdolek / template-worker.php
Last active August 29, 2015 14:01
Download attached images from a wordpress blog and save them into folders based on post title under uploads dir
<?php
/**
* Template Name: worker
*/
$args = array(
'posts_per_page'=> '-1',
'post_type'=> 'post',
'post_status' => array('publish'),
'order' => 'ASC',
@cdolek
cdolek / gist:a015abc3c09808fb14b7
Created October 31, 2014 00:50
haproxy v0.5 configuration for mysql cluster load balancing
global
log 127.0.0.1 local0 notice
chroot /var/lib/haproxy
user haproxy
group haproxy
# daemon
defaults
log global
# mode http
@cdolek
cdolek / gist:b72c81f813f03b043e37
Last active August 29, 2015 14:09
apache exclude static assets from access log
SetEnvIf Request_URI "\.gif$|\.jpg$|\.js$|\.css$|\.ico$|\.png$|\.ttf$|\.woff$|\.eot$|\.svg$|\.jpeg$|\.txt$" is_static
CustomLog /var/yourlogs/apache.access_log combined env=!is_static
@cdolek
cdolek / gist:89e24d71ce1a63c16e2d
Last active August 29, 2015 14:14
collecting vimeo video titles and links from vimeo.com // works on console
// paste
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// wait and paste
jQuery.noConflict();
// each paste will print the list on console, copy and paste + remove unnecessary lines
var a = jQuery('#browse_content li a');
@cdolek
cdolek / gist:4ad30938a88219811f5c
Created February 13, 2015 20:04
Creating folders from 0 to 12 -- zero padded (works on mac os x)
mkdir $(seq -f '%02.0f' 1 12)
creates folders:
01 02 03 04 05 06 07 08 09 10 11 12
@cdolek
cdolek / innodb_to_myisam.sql
Last active August 29, 2015 14:16
convert innodb to myisam - alter table print
SELECT
CONCAT(
'ALTER TABLE ',
TABLE_SCHEMA,
'.',
TABLE_NAME,
' ENGINE = MyISAM;'
)
FROM
information_schema. TABLES
@cdolek
cdolek / gist:f8952920e53b3cf6ac57
Created March 10, 2015 22:59
wordpress set proper file and folder permissions
# find all files forward this directory and set 644
sudo find . -type f -exec chmod 644 {} +
# find all directories forward and set 755
sudo find . -type d -exec chmod 755 {} +
@cdolek
cdolek / gist:d9a795b0eeaf03c62bb4
Last active August 29, 2015 14:23
fix broken homebrew
# PROBLEM ****************************************************************************
error: Your local changes to the following files would be overwritten by merge:
Library/Formula/node.rb
Please, commit your changes or stash them before you can merge.
Aborting
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master
######################################################################################
# FIX BELOW -------------------------
cd $(brew --repository)
@cdolek
cdolek / gist:631e0e32c359efece02f
Last active August 29, 2015 14:24
speedtest from terminal
# via http://binarynature.blogspot.com/2013/03/measure-internet-connection-speed-from-linux-command-line.html
wget -O speedtest-cli https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py && chmod +x speedtest-cli && ./speedtest-cli
@cdolek
cdolek / gist:71fecaa252a5672c923e
Created October 19, 2015 03:40
Google Spreadsheet Script
function findDateFromCalendarByName( find , timer ){
if ( find == '' ) { return; }
var ss = SpreadsheetApp.getActiveSpreadsheet(), output = [];
// var searchData = ss.getSheetByName('Calendar').getDataRange().getValues();
var searchData = ss.getSheetByName('Calendar').getRange("A1:P10").getValues();
for(var j=0, jLen=searchData.length; j<jLen; j++) {