Skip to content

Instantly share code, notes, and snippets.

import {Component} from 'angular2/core';
import {NgFor} from 'angular2/common';
import {Http} from 'angular2/http';
import template from './clients.html';
import {CanActivate, OnActivate, ROUTER_DIRECTIVES, RouteConfig} from 'angular2/router';
import {Service} from './clientResource';
import {Client} from '../classes/Client'
import {Component, View, Input, Output, EventEmitter} from 'angular2/core';
import {NgFor, NgClass, NgIf} from 'angular2/common';
import {ROUTER_DIRECTIVES} from 'angular2/router';
import template from './editable.html';
import styles from './editable.css';
import * as alerts from 'Utils/alerts'
const headers = {
'Authorization': (()=>getJWT())(),
'Accept': 'application/json, text/plain, */*',
@iksose
iksose / ng1_ng2.js
Last active December 26, 2015 01:00
// angular 1
import template from './navbar.html';
import './navbar.styl';
let Component = {
restrict: 'E',
bindings: {},
template,
controller: Home
import queryString from "query-string";
let _route = "api/v2.0/";
const headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
};
const verbs = {
@iksose
iksose / jsbeautifier-es6-hacks
Last active January 28, 2017 15:35 — forked from loopmode/jsbeautifier-es6-hacks
Some (ugly!) hacks to fix es6/es7 formatting problems in jsbeautifier. I use it with the "html/css/js prettify" plugin for Sublime Text
// in Sublime Text, Preferences -> Browse Packages, find HTML-CSS-JS Prettify/scripts/node_modules/js-beautify/js/lib/beautify.js
// find the last line of the 'beautify' function, and place the next lines just before 'return sweet_code';
// https://gist.github.com/loopmode/d091bce3b76efaf15d63
// es7 decorators
sweet_code = sweet_code.replace(/@\n/g, '@');
sweet_code = sweet_code.replace(/\)@\s/g, ')\n@');
sweet_code = sweet_code.replace(/ @ /g, ' @');
sweet_code = sweet_code.replace(/@\s/g, '\n@');
// destructuring/spread: imports
@iksose
iksose / gist:4ca3772785f54005123a
Last active August 29, 2015 14:12
es6 symbols
const privateFoo = Symbol("foo");
function Public() {
this[privateFoo] = "bar";
}
Public.prototype.method = function () {
// Do stuff with `this[privateFoo]`...
};
@iksose
iksose / uri.js
Created August 24, 2014 15:39 — forked from jlong/uri.js
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"
<ul>
<li ng-repeat="item in items | orderObjectBy:'color':true">{{ item.color }}</li>
</ul>
var OAuth2 = require('OAuth').OAuth2;
var https = require('https');
var oauth2 = new OAuth2(KEY, SECRET, 'https://api.twitter.com/', null, 'oauth2/token', null);
oauth2.getOAuthAccessToken('', {
'grant_type': 'client_credentials'
}, function (e, access_token) {
console.log(access_token); //string that we can use to authenticate request
var options = {
@iksose
iksose / gist:feeb9693d5d45a234095
Last active August 29, 2015 14:02
atom angular.js atom syntax
{
"match": "(?<!\\.)\\b(.forEach|.then)(?!\\s*:)\\b",
"name": "entity.name.function.js"
},
// matches .then & .forEach
{
"match": "(?<=\\).)(t(he(n)))\\b",
"name": "entity.name.function.js"