Skip to content

Instantly share code, notes, and snippets.

View mmurray's full-sized avatar

Michael Murray mmurray

View GitHub Profile
import rclpy
from rclpy.node import Node
from rclpy.time import Time
from std_msgs.msg import String
from tf2_ros import TransformException
from tf2_ros.buffer import Buffer
from tf2_ros.transform_listener import TransformListener
class FrameListener(Node):
import (
"fmt"
"http"
"strconv"
)
func getUserId(r *http.Request) (int64, error) {
c, err := r.Cookie("uid")
if err != nil {
return 0, err
@mmurray
mmurray / gist:9dfe80e269972f470558
Created September 2, 2014 20:02
scala example
import play.api.mvc.RequestHeader
def getUserId()(implicit request: RequestHeader) = {
request.cookies.get("uid").map(_.value.toLong).filter(_ > 0)
}
import subprocess
import sys
import time
import os
def start(args, logfile, errfile):
if os.name == 'nt':
subprocess.check_call('"..\\sbt\\sbt.bat" assembly', shell=True, cwd="blaze", stderr=errfile, stdout=logfile)
else:
subprocess.check_call("../sbt/sbt assembly", shell=True, cwd="blaze", stderr=errfile, stdout=logfile)
class Foo {
def fetchLatestActivityStats(orgCode: String): Future[String] = {
val yesterday = DateTime.now - 1.day
recursivelyLatestFetchActivityStats(yesterday, orgCode, 0)
}
def recursivelyLatestFetchActivityStats(
date: DateTime, org: String, errCount: Int): Future[String] = {
JavaScript(/*
* This is a build writing function for RequireJS configuration files. The purpose of it is to substitute any string literals that
* have a value starting with libPath. The libPath is used to determine the name of a module that can be found in paths.
* For example if libPath is "lib/" and paths is {"underscorejs/underscore":"http://somecdn/underscorejs"} then any string literals
* containing "lib/underscorejs/underscore" will be substituted with "http://somecdn/underscorejs/underscore".
*
* The function is intended to perform well given the initial scanning phase. Once the substitution array is collected
* then it is looped over and string concatenations are performed. The common scenario of a file not having anything
* to substitute results in only one concatenation. There are only (n * 2) + 1 concatenations to perform where n
* is the number of substitutions.
@mmurray
mmurray / maxcdn_purge.py
Created June 19, 2014 01:16
ansible_maxcdn_purge
#!/usr/bin/python
import datetime
import json
import os
from maxcdn import MaxCDN
def main():
module = AnsibleModule(
argument_spec = dict(
@mmurray
mmurray / react-router-link.js
Created May 29, 2014 15:23
react-router-link.js
// Put this where you want the widget to appear:
<ci:widget />
// Put this at the bottom fo the page:
<!-- clickigniter -->
<script type="text/javascript">
(function() {
{
"results": [
{
"title": "foo",
"url": "http://bar"
},
{
"title": "foo",
"url": "http://bar"
},