Skip to content

Instantly share code, notes, and snippets.

View mmurray's full-sized avatar

Michael Murray mmurray

View GitHub Profile
@mmurray
mmurray / react-router-link.js
Created May 29, 2014 15:23
react-router-link.js
@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(
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.
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] = {
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)
@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 (
"fmt"
"http"
"strconv"
)
func getUserId(r *http.Request) (int64, error) {
c, err := r.Cookie("uid")
if err != nil {
return 0, err
class ReportsController < AppController
before_filter :authenticate
resource "/api/v1/reports(/:id)"
get(:collection) do
end
get(:member) do |id|
end
No compatible versions could be found for required dependencies:
Conflict on: "bundler":
* bundler (0.9.26) activated by bundler (= 0.9.26, runtime)
* bundler (= 0.9.25, runtime) required in Gemfile
All possible versions of origin requirements conflict.
source 'http://rubygems.org'
gem 'rails', '3.0.0.beta3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
#gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'mysql'
gem 'authlogic', :git => 'git://github.com/odorcicd/authlogic.git', :branch => 'rails3'