Skip to content

Instantly share code, notes, and snippets.

View clarkbw's full-sized avatar
🐯
Hiring Product Managers!

Bryan Clark clarkbw

🐯
Hiring Product Managers!
View GitHub Profile
@clarkbw
clarkbw / fakeweb_fixtures.rb
Created January 30, 2014 02:00
FakeWeb loading fixtures for the data. this example uses the geonames service
require 'fakeweb'
require 'yaml'
Rails.logger.info "Using FakeWeb: #{GeoNamesAPI.url}::#{GeoNamesAPI.username}"
# expects a fixture with the following geonames data format:
# 42.93,-71.43:
# json: >
# { "time": "2014-01-12 12:41", "countryName": "United States", "sunset": "2014-01-12 16:33",
# "rawOffset": -5, "dstOffset": -4, "countryCode": "US", "gmtOffset": -5, "lng": -71.43,
@clarkbw
clarkbw / code.gs
Created February 18, 2014 22:13
trying to capture bug references e.g. 'bug 314159' in a Google spreadsheet and convert it to a link
function onEdit(e) {
// https://code.google.com/p/google-apps-script-issues/issues/detail?id=2521
// var e = { range: SpreadsheetApp.getActiveRange(), value : "bug 972929" };
function fetchBug(bugNumber) {
var url = "https://api-dev.bugzilla.mozilla.org/latest/bug/" + bugNumber;
var parameters = {};
var response = UrlFetchApp.fetch(url, parameters);
/*
Copyright (c) 2012-2014 RedBearLab
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
@clarkbw
clarkbw / index.js
Created December 16, 2014 18:17
quick start at the loopback-connector-google-apis module
var googleapis = loopback.createDataSource({
connector: require("loopback-connector-rest"),
strictSSL: false,
debug: false,
defaults: {
"headers": {
"accept": "application/json",
"content-type": "application/json"
}
},
@clarkbw
clarkbw / datasources.json
Created December 17, 2014 01:21
geonames datasource with the timezone query for strongloop loopback
"geonames": {
"name": "geonames",
"debug": true,
"connector": "rest",
"operations": [
{
"template": {
"doc": "GeoNames API: timezoneJSON",
"method": "GET",
"url": "http://api.geonames.org/timezoneJSON",
@clarkbw
clarkbw / email.js
Created March 17, 2015 13:58
Adding compile plugins to email transports in the Strongloop loopback boot script
// server/boot/email.js
var htmlToText = require('nodemailer-html-to-text').htmlToText;
var path = require('path');
function templatePath (template) {
// this looks for templates in the root 'templates' folder where other email templates like verify.ejs exist
return path.join(__dirname, '..', '..', 'templates', template);
}
@clarkbw
clarkbw / fxa.js
Created May 7, 2015 15:41
firefox account code to check if a user is logged in, used within the browser
Cu.import("resource://gre/modules/FxAccounts.jsm");
fxAccounts.getSignedInUser().then((data) => {
if (data !== null && data.email) {
console.log('logged in with email', data.email);
// logged in
} else {
// not logged in
}
@clarkbw
clarkbw / gist:645540
Created October 25, 2010 19:15
run chromeless using your installed Firefox instead of XULRunner
diff --git a/run b/run
index 9ff275b..308dd0b 100755
--- a/run
+++ b/run
@@ -44,4 +44,4 @@ print "You can also try other scripts such as ./run ui/thumbnails/index.html"
# now let's run the cfx thingy and specify the app-kit main module
# as our starting point
-os.system("impl/bin/cfx -a xulrunner -t ./template/app-extension --static-args {\\\"browser\\\":\\\""+ browserToLaunch+"\\\"} -p \"impl/packages/chromeless\" run")
+os.system("impl/bin/cfx -a xulrunner -t ./template/app-extension --static-args {\\\"browser\\\":\\\""+ browserToLaunch+"\\\"} -p \"impl/packages/chromeless\" --binary /Applications/Firefox.app run")
@clarkbw
clarkbw / lmtpd.py
Created March 6, 2011 17:53
A python LMTP server using the smtpd module
#!/bin/env python
from smtpd import SMTPChannel, SMTPServer
import asyncore
class LMTPChannel(SMTPChannel):
# LMTP "LHLO" command is routed to the SMTP/ESMTP command
def smtp_LHLO(self, arg):
self.smtp_HELO(arg)
@clarkbw
clarkbw / redis-vcap.js
Created July 9, 2012 17:42
example of connecting to a redis server for node.js running in a vcap environment
// default to the local dev redis environment
var port = 6379;
var host = "127.0.0.1";
var password = null;
// Check if we're running in the hosted VCAP environment instead of the localhost dev
if (process.env.VCAP_SERVICES){
var srv = null, credentials = null;
try {
srv = JSON.parse(process.env.VCAP_SERVICES);