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
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())
# 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 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
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
* {
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;
}
groups = YAML.load_file('./groups.json')
groups.each do |item|
group = Group.create({
name: item['name'].slice(0, 25),
description: item['description'].slice(0, 128),
banner: item['banner'],
members_count: item['members_count'],
privacy: 'public'
})
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
@8bitDesigner
8bitDesigner / start-working.scpt
Last active February 26, 2024 07:11
My magnum opus: a script to open and close tabs in Chrome
# 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,
@8bitDesigner
8bitDesigner / README.md
Last active August 14, 2022 05:25
Tiny chat server

Usage

  1. PORT=1337 node index to start the server
  2. telnet localhost 1227 to connect to the server
@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
}))