Skip to content

Instantly share code, notes, and snippets.

View parris's full-sized avatar

Parris Khachi parris

  • Discord
  • San Francisco
View GitHub Profile
@parris
parris / XMLParser.js
Created June 8, 2012 20:31
XML to JS Object (JSON), jQuery/jasmine
function xmlParser(node) {
var i = 0;
var attrs = node.attributes;
var nodes = node.childNodes;
var jsNode = new Object();
for(i;i<attrs.length;i++){
jsNode[attrs[i].name] = attrs[i].value;
}
@parris
parris / .bash_profile
Created November 30, 2012 08:07
Bash_Profile, Colors on mac
#make sure to run: git config --global color.ui true
function parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\*\1/'
}
case "$TERM" in
xterm-*color) color_prompt=yes;;
esac
###
Listens for clicks on a tags, if relative and the target is not blank it will use pushState
otherwise we fall through to normal click handling. Note preventDefault might need to be
handled better in older browsers.
###
hijackRelativeURLs = ->
document.addEventListener('click', (e) ->
element = e.target
if element?.nodeName == 'A'
@parris
parris / mixable.coffee
Created April 28, 2014 09:52
(We now have a repo/npm package: https://github.com/parris/mixablejs) Mixin class for coffeescript. Based on Angus Croll style mixins and backbone.advice.
_ = require('lodash')
class Mixable
constructor: ->
@initialize()
initialize: ->
@addToObj: (objectName, dictionary) ->
@parris
parris / button_3d.scss
Created June 1, 2014 08:44
3d button using Bourbon with animations. Demo Here: http://codepen.io/anon/pen/Czlvu
@import '../libs/bourbon/css3/_inline-block';
@import '../libs/bourbon/css3/_transition';
@import '../libs/bourbon/css3/_transform';
@import '../globals';
@mixin flat3DButton($color) {
$inverted_color: invert(mix(invert($color), $color, 25%));
@include inline-block();
@parris
parris / backbone_raphael_mixin.js
Created June 3, 2014 20:20
Mixes into Backbone.View to provide Raphael based views
define(function(require) {
// forked from https://github.com/tomasAlabes/backbone.raphael
'use strict';
function addMixin(mixinOptions) {
this.clobber({
setElement: function (element, delegate, undelegateEvents) {
if (this.el && undelegateEvents) {
this.undelegateEvents();
define(function(require) {
'use strict';
require('stickit');
return function(options){
// NOTE: this assumes inputs
var bindingDefaults = {
events: ['blur', 'paste', 'change'],
onSet: 'onSet'
define(function(require) {
var Backbone = require(‘backbone’),
backboneCanvasMixin = require(‘components/shapes/mixins/backbone_raphael_mixin’),
isMovable = require(‘components/shapes/mixins/is_movable’)
isRotatable = require(‘components/shapes/mixins/is_rotatable’)
// … and more ;
return Backbone.View.extend({ … })
.mixin(backboneCanvasMixin)
@parris
parris / mocha.opts
Created August 4, 2014 04:17
ReactJS Mocha.opts
--require should
--reporter dot
--ui bdd
--debug
--compilers coffee:coffee-react/register
--recursive
@parris
parris / browserify.coffee
Created August 4, 2014 05:31
Gulp using coffee-reactify
gulp = require 'gulp'
browserify = require 'gulp-browserify'
rename = require 'gulp-rename'
gulp.task 'js', ->
gulp.src('./public/src/app.coffee', { read: false })
.pipe(browserify({
transform: ['coffee-reactify'],
extensions: ['.coffee'],
}))