Skip to content

Instantly share code, notes, and snippets.

$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 / apt-key
Created July 9, 2014 07:57
apt-key
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 54422A4B98AB5139
@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;
echo 300 | sudo tee /sys/class/backlight/intel_backlight/brightness
@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
##############################################################################
# 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:3d3d9769bbd59c8d6339
Created July 13, 2015 22:14
Docker containers can't resolve DNS on Ubuntu 14.04 Desktop Host
sudo apt-get install bridge-utils
pkill docker
iptables -t nat -F
ifconfig docker0 down
brctl delbr docker0
sudo service docker start
@weivall
weivall / gist:21e5cf991b6774e474a5
Last active August 29, 2015 14:27
extjs debug
// to capture ALL events use:
Ext.util.Observable.prototype.fireEvent =
Ext.util.Observable.prototype.fireEvent.createInterceptor(function() {
console.log(this.name);
console.log(arguments);
return true;
});
// to capture events for a particular component:
Ext.util.Observable.capture(
@weivall
weivall / gist:94925689cd590513a4a5
Created September 30, 2015 08:00
Nginx compilation with js module
# Obtain the latest source for NGINX from http://nginx.org/en/download.html
$ wget http://nginx.org/download/nginx-1.9.5.tar.gz
$ tar -xzvf nginx-1.9.5.tar.gz
# Obtain the development sources for nginScript
$ hg clone http://hg.nginx.org/njs
# Build and install NGINX
$ cd nginx-1.9.5
$ ./configure \
@weivall
weivall / gist:1941425
Created February 29, 2012 15:11
simulateClick
function simulateClick() {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
var cb = document.getElementById("checkbox");
var canceled = !cb.dispatchEvent(evt);
if(canceled) {
// A handler called preventDefault
alert("canceled");
} else {