Skip to content

Instantly share code, notes, and snippets.

@smulube
smulube / tenancy.go
Created November 2, 2021 10:36 — forked from glerchundi/tenancy.go
tenancy
package tenancy
import (
"context"
"database/sql"
"database/sql/driver"
"errors"
"fmt"
"github.com/lib/pq"

Keybase proof

I hereby claim:

  • I am smulube on github.
  • I am smulube (https://keybase.io/smulube) on keybase.
  • I have a public key ASBKAGAtyIuqq8ySBIoUphPanSbLQkTbokFIvpMgqTy7gwo

To claim this, I am signing this object:

@smulube
smulube / graphite.md
Created September 5, 2016 10:18 — forked from relaxdiego/graphite.md
Installing Graphite in OS X Mavericks

Follow these steps to install graphite on OS X Mavericks.

Prerequisites

  • Homebrew
  • Python 2.7
  • Git

Install dependencies

Install Cairo and friends

@smulube
smulube / example_lambda_function.js
Created September 3, 2015 14:23
Example function to run on AWS lambda
var https = require('https');
/**
* Pass the Github user login as `event.login`.
* For more information see the HTTPS module documentation
* at https://nodejs.org/api/https.html.
*
* Will succeed with a custom body containing just the user's name and public repos
*/
exports.handler = function(event, context) {
var source = 'contract metaCoin { mapping (address => uint) public balances; function metaCoin() { balances[msg.sender] = 10000; } function sendCoin(address receiver, uint amount) returns(bool sufficient) { if (balances[msg.sender] < amount) return false; balances[msg.sender] -= amount; balances[receiver] += amount; return true; } }';
@smulube
smulube / HmacUtils.java
Last active November 15, 2017 13:38
Java helper to generate a hex SHA1 HMAC suitable for generating device activation code for Xively.
// Copyright (c) 2003-2013, LogMeIn, Inc. All rights reserved.
// This is part of Xively4J library, it is under the BSD 3-Clause license.
package com.xively.client.utils;
import java.math.BigInteger;
import java.security.GeneralSecurityException;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
@smulube
smulube / gist:5830587
Created June 21, 2013 11:23
xively datapoints tests
import xively
import datetime
FEED_ID=123
API_KEY="123abc"
api = xively.XivelyAPIClient(API_KEY)
feed = api.feeds.get(FEED_ID)
@smulube
smulube / gist:5798165
Created June 17, 2013 16:20
Upload data to Xively using Net::HTTP
require 'net/http'
require 'json'
require 'time'
feed_id = YOUR_FEED_ID
api_key = "YOUR_API_KEY"
payload = { :version => "1.0.0", :datastreams => [
{ :id => "Temperature", :at => Time.now.iso8601, :current_value => "17.2"}
]}.to_json
#include <SPI.h>
#include <Ethernet.h>
#include <HttpClient.h>
#include <Cosm.h>
#define API_KEY "YOURAPIKEY" // your Cosm API key
#define FEED_ID YOURFEEDID // your Cosm feed ID
// MAC address for your Ethernet shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
@smulube
smulube / cosm_currentcost.py
Last active October 12, 2015 14:58
Basic script to read data from a CurrentCost CC128 and post that data to Cosm
#!/usr/bin/env python
import serial
import xml.etree.ElementTree as ET
import sys
import requests
import json
import time
import syslog