Skip to content

Instantly share code, notes, and snippets.

View jasonjohnson's full-sized avatar
👾

Jason Johnson jasonjohnson

👾
View GitHub Profile
@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;
#!/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 / 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;
}
@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) {
; 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!
(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]
(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)
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'
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="2.3" jmeter="2.8 r1393162">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="eventlet + multiprocessing" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>