Skip to content

Instantly share code, notes, and snippets.

Avatar

Paul Sweeney 8bitDesigner

  • Fullscreen, Inc.
  • Los Angeles
View GitHub Profile
@8bitDesigner
8bitDesigner / thing.js
Last active Aug 29, 2015
Copy the title and link of every selected TP card
View thing.js
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
}))
@8bitDesigner
8bitDesigner / start-working.scpt
Last active Aug 29, 2015
My magnum opus: a script to open and close tabs in Chrome
View start-working.scpt
# The name of the folder that'll contain or bookmarks
set myFolderTitle to "Work Bookmarks"
# And here we take every bookmark in that folder, open it in
# a new tab, and delete it
tell application "Google Chrome"
set myFolder to first item of ¬
(every bookmark folder in every bookmark folder whose title is myFolderTitle)
# Currently Chrome crashes when adding a bookmark to an empty folder,
View gist:9377381
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
View awesome.css
* {
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;
}
View gist:5ce874349b4901595a06
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
View gist:15295fcd2b8216cf0bde
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
View gist:c0ed753b93e80e56d49e
# 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(@))
View gist:09c025a0a260f53dbfa0
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())
View directive.coffee
app.directive 'dingus', ->
controller: ($scope, $filter) ->
$scope.someText = ->
$filter('translate')('translation-key', some: values})
View _readme.md

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.