Skip to content

Instantly share code, notes, and snippets.

View MarkBennett's full-sized avatar

Mark Bennett MarkBennett

View GitHub Profile
@MarkBennett
MarkBennett / example.js
Created May 17, 2013 18:08
An example of seperating business logic from the DOM
function talk_to_webtrends(name, path) {
// Do WebTrends stuff I don't know here
}
$(".web-trends-link").click(function() {
var $elem, name, path;
$elem = $(this);
name = $elem.data("wtName");
path = window.location.path;
@MarkBennett
MarkBennett / delete_merged_branches.sh
Created April 17, 2013 19:28
Inspired by @nathany I took a stab at my own script to remove old git branches.
branches=$(git branch --merged | grep -v "master$")
for branch in $branches
do
echo "Removing old branch '$branch'"
git branch -d $branch
done
#! /bin/bash
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the unicorn web server
# Description: starts unicorn
@MarkBennett
MarkBennett / setIntervalSpec.js
Created March 9, 2013 21:14
Instead of requiring that the first call to setInterval() be setInterval(animate, 1000/30) just require that a call be made once.
// ...snip.. from test.js:49
describe("setInterval", function() {
it("should have been called", function() {
setIntervalSpy.should.have.been.called;
});
it("with 'animate' as its first parameter", function() {
setIntervalSpy.should.have.been.calledWith(animate);
});
@MarkBennett
MarkBennett / Command run to build dart
Last active December 14, 2015 05:59
Getting an error when trying to build Dart on Mac OS 10.8.2 with XCode 4.6
./tools/build.py --arch=ia32 &> dart_build_output

Google+ JavaScript Community FAQs

These are frequently asked question in the JavaScript Community.

  1. How do I do thing in Java?

That's a great question! Please find a Java community on Google+ to ask. JavaScript is not the same as Java. Here's a good explanation of the differences between Java and JavaScript: http://www.dannyg.com/ref/javavsjavascript.html.

@MarkBennett
MarkBennett / npm-g-list
Last active December 10, 2015 13:18
Details of a failing Testacular configuration. This is running on Mac OS 10.8.2 with Node v0.8.16 installed from the Node pkg installer.
/usr/local/share/npm/lib
├─┬ coffeelint@0.5.2
│ ├── coffee-script@1.3.3
│ ├─┬ glob@3.1.13
│ │ ├── graceful-fs@1.1.14
│ │ ├── inherits@1.0.0
│ │ └─┬ minimatch@0.2.7
│ │ └── lru-cache@2.0.4
│ └─┬ optimist@0.3.5
│ └── wordwrap@0.0.2
@MarkBennett
MarkBennett / main.js
Last active December 10, 2015 09:28
Am I misunderstanding how to use Angular/q deferred? Why does the result of deferred.resolve() never seem to make it into $scope.nextEvent. Thanks!
'use strict';
clientApp.controller('MainCtrl', function($scope, events) {
events.requestNextEvent().then(function(next_event) {
$scope.nextEvent = next_event;
});
});
@MarkBennett
MarkBennett / talk.txt
Created November 20, 2012 04:05
Celluloid Talk
_____ _ _ _ _ _
/ __ \ | | | | | (_) | |
| / \/ ___| | |_ _| | ___ _ __| |
| | / _ \ | | | | | |/ _ \| |/ _` |
| \__/\ __/ | | |_| | | (_) | | (_| |
\____/\___|_|_|\__,_|_|\___/|_|\__,_|
@MarkBennett
MarkBennett / gist:4041931
Created November 8, 2012 21:51
Question copier
source_topic = Topic.find(2813)
destination_topic_id = 2811
source_topic.questions.each do |q|
attribs = {
account_id: q.account_id,
created_by: q.created_by,
item_bank_id: q.item_bank_id,
topic_id: destination_topic_id,
points: q.point,