Skip to content

Instantly share code, notes, and snippets.

View BinaryMuse's full-sized avatar
🏳️‍🌈
Just gayin' up the place the best I can

Michelle Tilley BinaryMuse

🏳️‍🌈
Just gayin' up the place the best I can
View GitHub Profile
@jessykate
jessykate / Jekyll nd Octopress Liquid tag for MathJax.rb
Created February 18, 2011 23:37
A simple liquid tag for Jekyll/Octopress that converts {% m %} and {% em %} into inline math, and {% math %} and {% endmath %} into block equations, by replacing with the appropriate MathJax script tags.
module Jekyll
class MathJaxBlockTag < Liquid::Tag
def render(context)
'<script type="math/tex; mode=display">'
end
end
class MathJaxInlineTag < Liquid::Tag
def render(context)
'<script type="math/tex">'
end
@TooTallNate
TooTallNate / starttls.js
Created March 1, 2011 01:40
Upgrade a regular `net.Stream` connection to a secure `tls` connection.
// Target API:
//
// var s = require('net').createStream(25, 'smtp.example.com');
// s.on('connect', function() {
// require('starttls')(s, options, function() {
// if (!s.authorized) {
// s.destroy();
// return;
// }
//

Introduction

Imagine one was required to create a web-based password management system (over SSL! :) with the following requirements:

  1. Individual users sign in to the system using their own unique pass phrase.
  2. This pass phrase should be enough to allow the user to use the system effectively (e.g. from a smartphone, etc.)--the point being that they should not have to keep a key file with them.
@BinaryMuse
BinaryMuse / gist:967149
Created May 11, 2011 19:35
Verifying CampusCruiser SSO Signature
require 'sinatra'
require 'base64'
require 'cgi'
require 'erb'
require 'openssl'
require 'nokogiri'
def get_sso_data(env)
CGI.unescape env["rack.request.form_hash"]["imsEnterprise"]
end
@ericallam
ericallam / app.coffee
Created November 8, 2011 20:02
Set certain regions of an Ace editor to readOnly
event = require('pilot/event')
Anchor = require('ace/anchor').Anchor
doc = ace_editor.session.getDocument()
editablePositions = [[1, 0, 2, 0]] # allow editong only the second row
jQuery.each editable, (index, row) ->
editablePositions.push [new Anchor(doc, row[0], row[1]), new Anchor(doc, row[2], row[3])]
Range = require('ace/range').Range
@dsosby
dsosby / gist:1823881
Created February 14, 2012 05:26
Jsonp & Clojurescript
(def tumblr-url "http://pipes.yahoo.com/pipes/pipe.run?_id=4ddef10340ec6ec0374cbd0f73bce819&_render=json")
(defn display-count [json-obj]
(let [data (js->clj json-obj :keywordize-keys true)
post-count (:count data)]
(js/alert (str "Number of posts: " post-count))))
(defn display-items [json-obj]
(let [data (js->clj json-obj :keywordize-keys true)
items (:items (:value data))
@gzoller
gzoller / kinetic.bezier.js
Created April 13, 2012 22:43
Kinetic Plug-Ins
/**
* KineticJS Bezier Extension
* Compatible with KineticJS JavaScript Library v3.8.0
* Author: Greg Zoller
* Date: Apr 12 2012
*/
///////////////////////////////////////////////////////////////////////
// Bezier
///////////////////////////////////////////////////////////////////////
@swannodette
swannodette / gist:3217582
Created July 31, 2012 14:52
sudoku_compact.clj
;; based on core.logic 0.8-alpha2 or core.logic master branch
(ns sudoku
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defn get-square [rows x y]
(for [x (range x (+ x 3))
y (range y (+ y 3))]
(get-in rows [x y])))
@cemeng
cemeng / gist:3355490
Created August 15, 2012 03:38
Jasmine, Angular, Rails, Coffeescript - my oh my

Goals:

  • Support Coffeescript testing
  • Headless - run from command line
  • Test can be written in Coffeescript

Test libraries, two main alternatives:

  • Jasmine
  • Mocha

Jasmine is older - actively maintained by PivotalLabs, de facto JS testing for Rails projects? So I'd expect there are more gems/projects that integrate Jasmine and Rails compared to Mocha (at the moment anyway).

Engineering topic: Less is more

I had a desktop wallpaper a while ago with a single quote, it read:

As a software developer, you are your own worst enemy. The sooner you realize that, the better off you'll be.

As developers, every line of code that we write increases the const of maintaining the project that the code is in. It doesn't matter how clean the code is, how well written it is, how much thought was put into it ahead of time or if it has been refactered: All code carries a debt that can only be paid in time.

The theme of this week's engineering essay: Use the least amount of code possible.