Skip to content

Instantly share code, notes, and snippets.

@weivall
weivall / index.html
Created February 12, 2013 09:31
A CodePen by Andrey. 3D objects in CSS - This is a demo for my blog post on creating 3D Worlds in HTML and CSS: http://blog.keithclark.co.uk/creating-3d-worlds-with-html-and-css/
<input id="box-toggle" type="checkbox">
<label for="box-toggle">Show geometry</label>
export EC2_KEYPAIR=<your keypair name> # name only, not the file name
export EC2_URL=https://ec2.<your ec2 region>.amazonaws.com
export EC2_PRIVATE_KEY=$HOME/<where your private key is>/pk-XXXXXXXXXXXXXXXXXXXXXXXXXXXX.pem
export EC2_CERT=$HOME/<where your certificate is>/cert-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pem
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk/
@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']"
@weivall
weivall / Find All Links on a Page
Created November 11, 2013 22:33
Find All Links on a Page
@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);
$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
find ./ -type f -exec dos2unix {} \;
@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