Skip to content

Instantly share code, notes, and snippets.

View technovangelist's full-sized avatar

Matt Williams technovangelist

View GitHub Profile
ConvertToCSV = (objArray,name) ->
array = if typeof objArray isnt "object" then JSON.parse objArray else objArray
str = ""
for item,i in array
line = "#{array[i]["date"]}, #{commaReplace name}"
for index of array[i]
if index isnt "date"
line += ", #{commaReplace array[i][index]}"
str += line + "\r\n"
str
@technovangelist
technovangelist / Get Secret Info From SquareSpace.coffee
Created February 10, 2012 20:43
Get Secret Info From SquareSpace and Store in Adobe Air Local Store
#b64_sha1 library used in this code is Base64 encode / decode from http://www.webtoolkit.info/
localStoreset= (objectName, newobject) ->
bytes=new air.ByteArray()
bytes.writeUTFBytes(newobject)
air.EncryptedLocalStore.setItem(objectName, bytes)
getSecretInfoFromSS = (user,pass)->
datatext = "encryptedPassword=#{encodeURIComponent(b64_sha1(pass))}&loginStyle=regular&SS_CHAIN_TO_ACTION=http%3A%2F%2WebpageToRedirectToWithSecrets%2Frelogin=true&username=#{user}"
@technovangelist
technovangelist / pusher.coffee
Created March 8, 2012 10:00
Pusher Test Client Web Page
$('#InputText').on 'change', ->
inputText = $(@)
$.ajax("http://localhost:8888/chat?from=#{$('#Name').val()}&content=#{inputText.val()}")
inputText.val('')
pusher = new Pusher('Get Your Own Key at Pusher.com')
channel = pusher.subscribe('ChatChannel')
channel.bind('chat', (data)->$('#OutputText').prepend("#{data.from} said #{data.content} <br>"))
@technovangelist
technovangelist / simpleserver.coffee
Created March 8, 2012 10:02
Simple Pusher Server
http = require 'http'
url = require 'url'
pusher = require 'node-pusher'
mykey = 'Get Your Own Key at Pusher.com'
mysecret = 'Get Your Swn Secret'
myappid = 'Get Your Own App'
myPusher = new pusher(
appId: myappid
@technovangelist
technovangelist / GetSSEmailAddress
Created March 23, 2012 14:07
Get the email address of any logged in Squarespace user
$ ->
$.ajax
url:"/member/#{Squarespace.Constants.AUTHENTICATED_USER_LOGIN}"
success: (data) ->
email = $(data).find('#email').val()
console.log(email)
# do something more interesting
@technovangelist
technovangelist / pls-import.php
Last active December 26, 2015 04:29
How to import a listing to Placester
<?php
function geturls($url) {
$apikey=PL_Options::get('placester_api_key');
$urls = array(
image => 'https://api.placester.com/v2/listings/media/temp/image?api_key=' . $apikey,
listing => 'https://api.placester.com/v2/listings?api_key=' . $apikey,
);
return $urls[$url];
@technovangelist
technovangelist / Listing HTML Override for functions.php
Last active January 2, 2016 00:19
This is an example of how to override the html for a list of listings
function matt_listing_method($return,$raw,$html){
$location = $raw['location'];
$cur_data = $raw['cur_data'];
$uncur_data = $raw['uncur_data'];
?>
<div class="listing">
<span>Address: <?php echo $location['address'].', '.$location['locality'].', '.$location['region'].' '.$location['postal'] ?></span>
<a href="<?php echo $cur_data['url'] ?>">Click Here to View Property</a> |
<a href="https://maps.google.com/maps?q=<?php echo $location['full_address'] ?>&hl=en&z=15<br />">View on a map</a>
@technovangelist
technovangelist / 1) HTML Block
Last active January 4, 2016 07:49
Shortcode Template for Area and Sub Area in Single Dropdown
<div class="search-item">
<label>Neighborhoods:</label>
<select id=hoodselect name='hood-select'>
<option value="">Any</option>
</select>
</div>
<div class="search-item">
<label>Min Beds:</label>[min_beds]
</div>
<div class="search-item">
@technovangelist
technovangelist / slidertest.php
Created February 20, 2014 16:30
Using RoyalSlider with Placester Property Images
<?php
/**
* Template Name: SliderTest
*/
wp_enqueue_style( 'royal_slider_css', get_template_directory_uri() . "/royalslider/royalslider.css");
wp_enqueue_style( "royal_slider_default_skin_css", get_template_directory_uri() . "/royalslider/skins/default/rs-default.css" );
wp_enqueue_script( "royal_slider_js", get_template_directory_uri() . "/royalslider/jquery.royalslider.min.js");
get_header( );
@technovangelist
technovangelist / gist:4326e9adde324874f6a2
Created November 4, 2014 18:19
Simplest code to create a metric on Google App Engine using Python
from dogapi import dog_http_api as api
api.api_key = 'YOUR_API_KEY'
api.application_key = 'YOUR_APPLICATION_KEY'
# Submit a single point with a timestamp of `now`
api.metric('page.views', 1000)
#see more examples here: http://docs.datadoghq.com/api/