Skip to content

Instantly share code, notes, and snippets.

View atomize's full-sized avatar
🎹
♩♩

Berti atomize

🎹
♩♩
View GitHub Profile
@atomize
atomize / run.php
Created April 8, 2013 23:52 — forked from greut/run.php
#!/usr/bin/env php
<?php
$app = function($request) {
$body = <<<EOS
<!DOCTYPE html>
<html>
<meta charset=utf-8>
<title>Hello World!</title>
@atomize
atomize / BuildQueryFromCheckBoxes.php
Last active December 15, 2015 18:59
Build MySQL query from checkboxes.
<?php
include("MYSQL2JSON.class.php");
//MySQL connect
$c = mysql_connect("useawsfordbduuuh.c345tgxpm1uqz.us-east-1.rds.amazonaws.com", "login", "password!");
mysql_select_db("database");
$json = new MYSQL2JSON(); //Create an object
$form = '<FORM
<form action="index.php" method="post">
<label><input type="checkbox" name="col[]" value="Asphalt">Asphalt</label><br>
@atomize
atomize / PHPinJSinHTML.html
Created April 4, 2013 03:24
php in js in html
<html>
<head>
<script type="text/javascript">
var myData = Array(); //create the blank array variable
//now add values to the array from PHP
<?php
@atomize
atomize / timeStrToSlashes.php
Created March 29, 2013 16:06
I use this to take dates formatted like 'Mon Apr 1 00:12:23 2013' and turn them in to '04/01/2013' in PHP
<?php
$time = "Mon Apr 1 00:00:00 2013"; // Has a rando extra space for example purposes
$pattern = '/\s\s+/'; // fix that rando extra space with regex and preg_replace()
$str = preg_replace($pattern, ' ', $time);
$str = strtotime($str); // convert the time to UNIX time using built-in strtotime() function of PHP
$str = date('m/d/Y', $str); // use date() to convert accurate UNIX time to desired format
echo "\n".$str."\n"; // big pimpin'
?>
@atomize
atomize / fix_OSX_VNC_Auth_Remmina.txt
Created February 14, 2013 13:13
When Remmina or other VNC clients throw "UNKNOWN AUTH TYPE" sorts of errors at you while trying to connect to OSX Leopard 10.5/OSX Server 10.5.8, run this command FROM THE TERMINAL OF THE MAC YOU ARE TRYING TO CONNECT TO.
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -verbose -activate -restart -agent -allowAccessFor -allUsers -privs -all -clientopts -setvnclegacy -vnclegacy yes -setvncpw -vncpw CHANGETHISTOAPASSWORDFORYOU
@atomize
atomize / getDPI.php
Created February 11, 2013 14:14
Get image DPI in flat PHP
function get_dpi($filename){
$a = fopen($filename,'r');
$string = fread($a,20);
fclose($a);
$data = bin2hex(substr($string,14,4));
$x = substr($data,0,4);
$y = substr($data,0,4);
return array(hexdec($x),hexdec($y));
@atomize
atomize / wgetTheWholeFcknSite
Created February 10, 2013 00:42
Mirror (download) and entire website with wget.
wget -p -m -k -K -E http://your.website.com/
@atomize
atomize / catURL.txt
Created February 5, 2013 05:33
Google Spreadsheet function to create concatenated URL callback from spreadsheet values
=ImportData(CONCATENATE("http://maps.google.com/maps/geo?output=kml&amp;q=",A1:D1))
@atomize
atomize / mapsScript.js
Created February 5, 2013 05:30
Google Apps Script Maps Service in Spreadsheets - Get Lon/Lat + Generate Map UI (original: http://www.vicfryzel.com/2010/11/11/doing-some-useful-things-with-maps-in-google-apps-script)
function getLatitudeLongitude($address) {
var geocode = Maps.newGeocoder()
.geocode($address);
// See http://goo.gl/5mr1N for reference
return geocode.results[0].geometry.location.lng + ', '+ geocode.results[0].geometry.location.lat;
}
function generateMap() {
var address = "111 8 Ave., New York, NY 10011";
var mapUrl = Maps.newStaticMap()
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();