Skip to content

Instantly share code, notes, and snippets.

View 8bitDesigner's full-sized avatar

Paul Sweeney 8bitDesigner

  • Cisco Meraki
  • Los Angeles
View GitHub Profile
@8bitDesigner
8bitDesigner / thing.js
Last active August 29, 2015 13:56
Copy the title and link of every selected TP card
copy($('.tau-selected.tau-card-v2').map(function(i, el) {
return $(el).data('card-data')
}).toArray().sort(function(a, b) {
return (a.type === b.type) ? 0 : a.type > b.type
}).map(function(obj) {
return window.location.origin + '/entity/' + obj.id + ' -- ' + '[' + obj.type + '] ' + obj.name
}))
var GitHub = require('github')
, Octopie = require('octopie')
, octopie = new Octopie({ options: '...' })
, gh = new GitHub({ version: '3.0.0' })
gh.authenticate({ type: 'oauth', token: process.env.GHTOKEN })
octopie.on('pull_request', function(data) {
myTestServer.startTesting(data, function(status) {
// from: http://ajaxorg.github.io/node-github/#statuses
* {
box-shadow: inset 0 0 0 10px #FF009A;
width: auto;
color: #FFF;
background: rgba(0, 0, 0, 0) url(http://herogamesworld.com/images/my%20little%20pony%20games.jpg) repeat;
}
videos = new Videos() # Create a collection of videos
videos.fetch() # Populate it with data from the server
videos.upload() # Create a new video
videos.fetchS3Credentials() # Possibly a private method? Applies to the resource as a whole
videos.models # Array of Video model instances
video = new Video(slug) # Create a new video instance for a specific video
video.fetch() # Fetch the model's data from the server
video.destroy() # Delete the model
video.set({attrs: 'here'}) # Update the model's attributes
class Foo
bar: -> 'bar' # Defining an instance method
Foo::baz = -> 'baz' # Appending an instance method on the class prototype
Foo.bacon = -> 'tasty' # Definining a method on the class itself
# Instance methods
foo = new Foo()
foo.bar() # bar
foo.baz() # baz
# In the class
class Model
fetch: (options = {}) ->
opts = _.extend({}, options)
_(opts).defaults
method: 'GET'
url: _.result(@, 'url')
cancellableHttpRequest(opts).then(_(@parse).bind(@)).then(_(@set).bind(@))
class Controller
constructor: ($injector) ->
@init.apply(@, @injectables.map((val) -> $injector.get(val)))
$injector.get('$scope').$on, '$destroy' => @deinit()
class MyController extends Controller
injectables: '$scope', '$modal'
init: ($scope, $modal) ->
@modal = $modal.open($scope.new())
app.directive 'dingus', ->
controller: ($scope, $filter) ->
$scope.someText = ->
$filter('translate')('translation-key', some: values})

Usage

node index.js <source server> <destination server> [optional cookie string]

cors-proxy accepts HTTP requests and proxies them to the destination server as though they originated from the source server. This allows you to, for example, develop locally and make CORS requests against a production or staging server.

@8bitDesigner
8bitDesigner / delta.js
Created July 24, 2014 23:28
Get the difference in styles between two HTML nodes
function styleDelta(a, b) {
var aStyles = window.getComputedStyle(a)
, bStyles = window.getComputedStyle(b)
, delta = {}
Object.keys(aStyles).forEach(function(key) {
var aVal = aStyles[key]
, bVal = bStyles[key]
if (aVal != bVal) {