Skip to content

Instantly share code, notes, and snippets.

View atomize's full-sized avatar
🎹
♩♩

Berti atomize

🎹
♩♩
View GitHub Profile
@atomize
atomize / GASjson2SS.js
Last active December 11, 2023 21:26 — forked from mhawksey/gist:1442370
Google Apps Script to read JSON and write to sheet
function getJSON(aUrl,sheetname) {
//var sheetname = "test";
//var aUrl = "http://pipes.yahoo.com/pipes/pipe.run?_id=286bbb1d8d30f65b54173b3b752fa4d9&_render=json";
var response = UrlFetchApp.fetch(aUrl); // get feed
var dataAll = Utilities.jsonParse(response.getContentText()); //
var data = dataAll.value.items;
for (i in data){
data[i].pubDate = new Date(data[i].pubDate);
data[i].start = data[i].pubDate;
}
@atomize
atomize / js_call_php.php
Created December 20, 2012 19:48
/** * AJAX API FOR PHP FUNCTION LIBRARY * Place your functions below the header and then call them by posting to the script with any kind of ajax : * $('#test').load('base/ajax/ajaxapi.php',{method:'sha256',params:"'batman','gargamelhatessmurfs'"}); for example. */
/**
* AJAX API FOR PHP FUNCTION LIBRARY
* Place your functions below the header and then call them by posting to the script with any kind of ajax :
* $('#test').load('base/ajax/ajaxapi.php',{method:'sha256',params:"'batman','gargamelhatessmurfs'"}); for example.
*/
if(function_exists(stripslashes(trim($_POST['method'])))){ //IF THE FUNCTION EXISTS (IN THIS SCRIPT)
$method = stripslashes(trim($_POST['method']));
$params = str_replace("'", '',stripslashes(trim($_POST['params']))); //strip single quotes if used
$opts= explode(',',$params); //turn the parameters string into an array
$function = new ReflectionFunction($method); //instantiate the function as an object
function uploadPdfOcr() {
authorize();
var key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // <-- developer key
var file = UrlFetchApp.fetch("http://somewhere.com/path/file.pdf").getBlob();
var metadata = { title: file.getName() }
var params = {method:"post",
oAuthServiceName: "drive",
oAuthUseToken: "always",
contentType: "application/pdf",
contentLength: file.getBytes().length,
/**
* 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();
@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()
@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 / 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 / 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 / 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 / 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'
?>