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 / 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);
@clarkbw
clarkbw / utils.js
Last active December 14, 2015 00:38
jetpack style loading (and unloading) of a stylesheet into XUL. Only useful for add-ons that need to change chrome UI.
const { CC, Ci } = require('chrome');
const { when: unload } = require('sdk/system/unload');
var ios = Cc['@mozilla.org/network/io-service;1'].getService(Ci.nsIIOService);
/* Helper that registers style sheets and remembers to unregister on unload */
exports.addXULStylesheet = function addXULStylesheet(url) {
var uri = newURI(url);
var sss = Cc["@mozilla.org/content/style-sheet-service;1"]
.getService(Ci.nsIStyleSheetService);
@clarkbw
clarkbw / test-stylesheet.js
Created February 21, 2013 00:24
Because you can't easily find a stylesheet in XUL by it's ID you have to look for the data attribute and compare that with what I created as the `css` variable.
function findStylesheet(document, name) {
var uri = data.url(name + ".css"),
css = "href=\"" + uri + "\" type=\"text/css\"",
ORDERED_NODE_SNAPSHOT_TYPE = 7, // XPathResult doesn't exist in context
xpath = null;
xpath = document.evaluate("//processing-instruction(\"xml-stylesheet\")",
document,
document.createNSResolver(document),
@clarkbw
clarkbw / persona.diff
Last active December 14, 2015 01:58
Adds persona support to the discourse platform using the omniauth-persona gem ( https://github.com/pklingem/omniauth-persona )
diff --git a/Gemfile b/Gemfile
index 6966c65..59e7dc3 100644
--- a/Gemfile
+++ b/Gemfile
@@ -34,6 +34,7 @@ gem "omniauth-openid"
gem "openid-redis-store"
gem "omniauth-facebook"
gem "omniauth-twitter"
+gem "omniauth-persona"
gem 'oj'
@clarkbw
clarkbw / users.yml
Created January 14, 2014 14:06
Devise user fixture for testing rails with users. confirm* items are only required if you've set :confirmable in your model.
bryan:
email: clarkbw@example.com
encrypted_password: <%= User.new.send(:password_digest, '1234567890') %>
confirmed_at: <%= Time.zone.now - 1.hour %>
confirmation_sent_at: <%= Time.zone.now - 2.hours %>
@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