Skip to content

Instantly share code, notes, and snippets.

View jasonjohnson's full-sized avatar
👾

Jason Johnson jasonjohnson

👾
View GitHub Profile
diff --git libcloud/compute/drivers/softlayer.py libcloud/compute/drivers/softlayer.py
index babc89c..92be797 100644
--- libcloud/compute/drivers/softlayer.py
+++ libcloud/compute/drivers/softlayer.py
@@ -108,7 +108,8 @@ class SoftLayerResponse(XMLRPCResponse):
class SoftLayerConnection(XMLRPCConnection, ConnectionUserAndKey):
responseCls = SoftLayerResponse
- endpoint = '/xmlrpc/v3/'
+ base_url = 'https://api.softlayer.com'
(ns httpjson.core
(:require [clj-http.client :as client]))
(defn create-db
[db]
(client/request {:as :json
:accept :json
:content-type :json
:method :put
:url (str "http://127.0.0.1:5984/" db)
(def connection {:host "127.0.0.1"})
(defn query [conn query]
(str (:host conn) ":" query))
(defn query-with-modifiers [conn query modifiers]
(str (:host conn) ":" query ":" modifiers))
(defmacro with-connection
[conn & body]
; I have a bunch of these "example"-type functions:
(defn example [a b c] (str a b c))
; Imagine incoming calls which look like this:
(def testing '(example 2 3))
; My naive first attempt. Prints the string "123"
(println (apply (partial (resolve (first testing)) 1) (rest testing)))
; So, I've pre-applied the first argument to the function!
@jasonjohnson
jasonjohnson / hash.php
Created March 4, 2012 04:10
PHP Hash Implementation using DJB
<?php
class Hash {
var $buckets = array();
function put($key, $value) {
$this->buckets[$this->generate_hash($key)] = $value;
}
function get($key) {
@jasonjohnson
jasonjohnson / MCAPI.php
Created January 16, 2012 11:31
MCAPI Original
<?php
class MCAPI {
// ..snip
function MCAPI($apikey, $secure=false) {
$this->secure = $secure;
$this->apiUrl = parse_url("http://api.mailchimp.com/" . $this->version . "/?output=php");
$this->api_key = $apikey;
}
#!/usr/bin/env python
import time
tick = 0
while 1:
step = time.time()
diff = step - tick
if diff > 0.025:
#!/usr/bin/env python
import time
tick = 0
while 1:
step = time.time()
diff = step - tick
if diff > 0.025:
@jasonjohnson
jasonjohnson / gist:161356
Created August 4, 2009 17:17
day_of_week
<?php
function day_of_week($day, $month, $year = null, $limit = 20) {
$found_day = false;
$days = array();
$time = mktime(0, 0, 1, $month, 1, ($year?$year:date('Y')));
if(date('Y', $time) == $day)
$found_day = true;