Skip to content

Instantly share code, notes, and snippets.

##############################################################################
# INSTALL isolated PHP 5.6 ZTS (Thread-safe) with pthreads on Ubuntu 14.04 ###
##############################################################################
1) Install necessary bison version
wget http://launchpadlibrarian.net/140087283/libbison-dev_2.7.1.dfsg-1_amd64.deb
wget http://launchpadlibrarian.net/140087282/bison_2.7.1.dfsg-1_amd64.deb
dpkg -i libbison-dev_2.7.1.dfsg-1_amd64.deb
dpkg -i bison_2.7.1.dfsg-1_amd64.deb
@weivall
weivall / gist:53eaf512c0b7d7572885
Created April 13, 2015 07:52
svg resize inkscape
#!/bin/bash
INK=/Applications/Inkscape.app/Contents/Resources/bin/inkscape
if [[ -z "$1" ]]
then
echo "SVG file needed."
exit;
fi
echo 300 | sudo tee /sys/class/backlight/intel_backlight/brightness
@weivall
weivall / gist:481b9bdb307ea5eacd43
Created February 23, 2015 12:25
Clean all tables MySQL
SET FOREIGN_KEY_CHECKS = 0;
SET @tables = NULL;
SELECT GROUP_CONCAT(table_schema, '.', table_name) INTO @tables
FROM information_schema.tables
WHERE table_schema = 'database_name'; -- specify DB name here.
SET @tables = CONCAT('DROP TABLE ', @tables);
PREPARE stmt FROM @tables;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
find ./ -type f -exec dos2unix {} \;
@weivall
weivall / apt-key
Created July 9, 2014 07:57
apt-key
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 54422A4B98AB5139
$ssss = $wpdb->get_results("select name, id from wp_cities");
foreach($ssss as $s){
$z = file_get_contents("http://maps.googleapis.com/maps/api/geocode/json?address={$s->name}&sensor=false");
$a = json_decode($z, true);
$lat = $a['results'][0]['geometry']['location']['lat'];
$lng = $a['results'][0]['geometry']['location']['lng'];
$wpdb->update(
'wp_cities',
array( 'lat' => $lat, 'lng' => $lng ),
array( 'id' => $s->id),
@weivall
weivall / Generate CSV file from a PHP array
Created November 11, 2013 22:38
Generate CSV file from a PHP array
function generateCsv($data, $delimiter = ',', $enclosure = '"') {
$handle = fopen('php://temp', 'r+');
foreach ($data as $line) {
fputcsv($handle, $line, $delimiter, $enclosure);
}
rewind($handle);
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);
@weivall
weivall / Find All Links on a Page
Created November 11, 2013 22:33
Find All Links on a Page
@weivall
weivall / gist:6207053
Created August 11, 2013 21:59
dEdit autodetect encoding
gsettings set org.gnome.gedit.preferences.encodings auto-detected "['UTF-8', 'WINDOWS-1251', 'CURRENT', 'ISO-8859-15', 'UTF-16']"