Skip to content

Instantly share code, notes, and snippets.

View fraserxu's full-sized avatar
🐢
No idea

Fraser Xu fraserxu

🐢
No idea
View GitHub Profile
@fraserxu
fraserxu / wiredcraft_logo
Created March 17, 2014 11:45
wiredcraft logo
@shama
shama / favorite_module_pattern.js
Last active August 29, 2015 13:57
My favorite node.js module pattern
function Animal(name) {
if (!(this instanceof Animal)) return new Animal(name);
this.name = name || 'unknown';
}
module.exports = Animal;
Animal.prototype.feed = function(food) {
food = food || 'food';
return 'Fed ' + this.name + ' some ' + food;
};
@fraserxu
fraserxu / gist:8020199
Created December 18, 2013 10:27 — forked from riywo/gist:5000181
# branch
$ git branch -d BRANCH # delete local BRANCH
$ git push origin :BRANCH # delete remote BRANCH
# tag
$ git tag -d TAG # delete local TAG
$ git push origin :refs/tags/TAG # delete remote TAG
@polotek
polotek / ember_hurdles.md
Last active March 30, 2017 05:37
Hurdles getting started with Ember.js

This is a brain dump of my experience trying to get something going with Ember.js. My goal was to get to know the ins and outs of the framework by completing a pretty well defined task that I had lots of domain knowledge about. In this case reproducing a simple Yammer feed. As of this time, I have not been able to complete that task. So this is a subjective rundown of the things I think make it difficult to get a handle on Ember. NOTE: My comments are addressing the Ember team and giving suggestions on what they could do to improve the situation.

App setup

The new guides have pretty good explanation of the various parts of the framework; routers, models, templates, views. But it's not clear how they all get strapped together to make something that works. There are snippets of examples all over the place like:

App.Router.map(function() {
  match('/home').to('home');
});
@steida
steida / gist:8592161
Created January 24, 2014 04:37
Gulp.js, keep the original folder structure, for side by side compilation.
var coffee = require('gulp-coffee');
var eventStream = require('event-stream');
var gulp = require('gulp');
var gutil = require('gulp-util');
var scriptsDirs = [
'bower_components/este-library/este/',
'client/',
'server/'
];
var $ = require('NodObjC');
$.import('Cocoa');
var installNSBundleHook = function() {
var cls = $.NSBundle;
if (cls) {
var bundleIdentifier = cls.getInstanceMethod('bundleIdentifier');
bundleIdentifier.setImplementation(function(val) {
@edwardhotchkiss
edwardhotchkiss / syntax.css
Created March 9, 2012 04:34 — forked from scotu/solarized.css
Solarized Light Pygments CSS / Jekyll
.highlight {
background-color: #efefef;
padding: 7px 7px 7px 10px;
border: 1px solid #ddd;
-moz-box-shadow: 3px 3px rgba(0,0,0,0.1);
-webkit-box-shadow: 3px 3px rgba(0,0,0,0.1);
box-shadow: 3px 3px rgba(0,0,0,0.1);
margin: 20px 0 20px 0;
overflow: hidden;
@mlynch
mlynch / auth.markdown
Last active September 4, 2020 18:11
AngularJS Authentication and CORS

Single Page Apps are ruling the world and AngularJS is leading the charge. But many of the lessons we learned in the Web 2.0 era no longer apply, and few are as drastically different as authentication.

CORS

CORS is an oft-misunderstood feature of new browsers that is configured by a remote server. CORS stands for Cross-Origin-Resource-Sharing, and was designed to make it possible to access services outside of the current origin (or domain) of the current page.

Like many browser features, CORS works because we all agree that it works. So all major browsers like Chrome, Firefox, and IE support and enforce it. By using these browsers, you benefit from the security of CORS.

That means certain browsers do not enforce it, so it is not relevant there. One large example is a native Web View for things like Cordova and Phonegap. However, these tools often have configuration options for whitelisting domains so you can add some security that way.

var uuids = angular.module('uuids', []);
uuids.factory("rfc4122", function () {
return {
newuuid: function () {
// http://www.ietf.org/rfc/rfc4122.txt
var s = [];
var hexDigits = "0123456789abcdef";
for (var i = 0; i < 36; i++) {
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
}
@insin
insin / app.jsx
Last active July 13, 2021 07:39
React Form Handling - handleFormInputChange (Live version: http://bl.ocks.org/insin/raw/082c0d88f6290a0ea4c7/)
var INPUT_TYPES = 'color|date|datetime|datetime-local|file|month|number|password|range|search|tel|text|time|url|week'.split('|')
var App = React.createClass({
getInitialState: function() {
return {}
},
onChange: handleFormInputChange,
render: function() {