Skip to content

Instantly share code, notes, and snippets.

View nem035's full-sized avatar
🐢
always learning

Nemanja Stojanovic nem035

🐢
always learning
View GitHub Profile
@nem035
nem035 / controllers.application.js
Last active August 31, 2016 15:35
Ember Event Queue
import Ember from 'ember';
const randomDelay = () => 500 + (Math.random() * 10000) % 2000;
function Field(lastChar) {
this.char = lastChar;
}
Field.prototype.save = function() {
return new Ember.RSVP.Promise((resolve, reject) => {
@nem035
nem035 / components.my-component.js
Created September 7, 2016 17:45
Injecting-store-in-Ember.Component
import Ember from 'ember';
export default Ember.Component.extend({
store: Ember.inject.service(),
storeType: null,
didInsertElement() {
this.set('storeType', Ember.typeOf(this.get('store')));
}
});
import Ember from 'ember';
export default Ember.Component.extend({
});
function MONAD(modifier) {
const prototype = Object.create(null);
function unit(value) {
const monad = Object.create(prototype);
monad.bind = function(f, ...args) {
return f(value, ...args);
};
if (typeof modifier === 'function') {
modifier(monad, value);
@nem035
nem035 / better-nodejs-require-paths.md
Created November 6, 2016 04:19 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

function * just (...values) {
yield * values;
};
function first (iterable) {
const iterator = iterable[Symbol.iterator]();
const { done, value } = iterator.next();
if (!done) return value;
};
@nem035
nem035 / CollatzSequence.js
Created January 9, 2017 20:58
(Memoized) code to print the Collatz Sequence for a given number. https://en.wikipedia.org/wiki/Collatz_conjecture
function collatzSequence() {
const storage = new Map();
function run(x) {
if (typeof x !== 'number') throw new TypeError('Argument must be a number');
let head = storage.get(x) || new ListNode(x);
let curr = head;
while (curr.value !== 1) {

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@nem035
nem035 / ember-cli-build.js
Created January 24, 2017 22:48 — forked from mathieul/ember-cli-build.js
Using ES7 decorators & async/await with Ember: example
// ...
var app = new EmberApp(defaults, {
hinting: false,
babel: {
includePolyfill: true,
optional: [
"es7.decorators",
"es7.classProperties",
"es7.asyncFunctions"
@nem035
nem035 / template-literals.md
Created January 25, 2017 05:11 — forked from dherman/template-literals.md
What can you do with ES6 string template literals?

DOM selectors

var elements = query`.${className}`;

Localization

var message = l10n`Hello ${name}; you are visitor number ${visitor}:n!