Skip to content

Instantly share code, notes, and snippets.

View matharden's full-sized avatar

Mat Harden matharden

View GitHub Profile
var doc = context.document
var selectLayersOfType_inContainer = function(layerType, containerLayer) {
// Filter layers using NSPredicate
var scope = (typeof containerLayer !== 'undefined') ? [containerLayer children] : [[doc currentPage] children],
predicate = NSPredicate.predicateWithFormat("(className == %@)", layerType),
layers = [scope filteredArrayUsingPredicate:predicate];
// Deselect current selection
@giuseppeg
giuseppeg / app-structure.md
Last active August 29, 2015 14:10
app front-end structure

Components (or modules) talk to each other via events.

  • vendor [3rd party scripts, this could as well be bower_components if you use bower]
  • core [app core functionalities/utilities]
  • component
    • component1
      • index.js [the actual js component]
      • spec.js [tests]
      • style.css [component styles]
  • index.partial.template
@tyom
tyom / .editorconfig
Last active April 12, 2018 08:48
Editorconfig settings
# http://editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
@Demwunz
Demwunz / devtools.md
Last active October 3, 2018 17:50
Development tools and useful links. Ongoing.
@nhunzaker
nhunzaker / viewport.js
Created October 23, 2012 19:29
Viewports in Phantom.js
// Viewport
//
// phantom.js viewport.js http://google.com 400
var args = require("system").args;
var url = args[1];
var width = args[2];
var height = args[3];
@n1k0
n1k0 / Howto.md
Created October 1, 2012 17:59
CasperJS test cli hooks example

Put test1.js and test2.js into a tests/ directory, then run the suite:

$ casperjs test tests/ --pre=pre.js --includes=inc.js --post=post.js
Test file: /Users/nperriault/tmp/pre-inc/pre.js                                 
Hey, I'm executed before the suite.
Test file: /Users/nperriault/tmp/pre-inc/tests/test1.js                         
# this is test 1
Hi, I've been included.
PASS Subject is strictly true
@michaelcox
michaelcox / SpecRunner.js
Last active January 11, 2024 06:05
Browser Unit Testing with Backbone Mocha Chai and RequireJS
require.config({
baseUrl: '/backbone-tests/',
paths: {
'jquery' : '/app/libs/jquery',
'underscore' : '/app/libs/underscore',
'backbone' : '/app/libs/backbone',
'mocha' : 'libs/mocha',
'chai' : 'libs/chai',
'chai-jquery' : 'libs/chai-jquery',
'models' : '/app/models'
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@necolas
necolas / README.md
Last active March 28, 2024 20:34
Experimenting with component-based HTML/CSS naming and patterns

NOTE I now use the conventions detailed in the SUIT framework

Template Components

Used to provide structural templates.

Pattern

t-template-name
@greystate
greystate / querystring.coffee
Created October 10, 2011 09:50
CoffeeScript QueryString class
# Provide easy access to QueryString data
class QueryString
constructor: (@queryString) ->
@queryString or= window.document.location.search?.substr 1
@variables = @queryString.split '&'
@pairs = ([key, value] = pair.split '=' for pair in @variables)
get: (name) ->
for [key, value] in @pairs