Skip to content

Instantly share code, notes, and snippets.

@BretFisher
BretFisher / checkForSettings.js
Created January 15, 2015 16:06
Meteor App Check for Ensuring You're Using --settings
// lets complain to server command line if you forgot --settings when running Meteor
Meteor.startup(function () {
if (Meteor.isServer) {
if (Object.keys(Meteor.settings).length === 0) {
console.log("You forgot to run Meteor with --settings!");
}
}
});
@ademuk
ademuk / wercker-dokku-deploy.yml
Created November 5, 2014 11:21
Wercker Dokku deploy
deploy:
steps:
- add-to-known_hosts:
hostname: $HOSTNAME
- add-ssh-key:
keyname: KEY
- script:
name: Push to dokku
code: |
git remote add dokku dokku@$HOSTNAME:$APP
@websymphony
websymphony / ecto_table_with_uuid_primary_key.exs
Last active September 7, 2016 07:46
Use UUIDs as primary key with Ecto - Phoenix Framework
defmodule Blog.Repo.Migrations.CreatePost do
use Ecto.Migration
def up do
create table(:posts, primary_key: false) do
add :id, :uuid, primary_key: true
add :title, :string
add :body, :text
@BJTerry
BJTerry / gist:32b491dc30788ec371e9
Created July 5, 2014 01:17
A naive way to get JQuery slide/fade animations in React.js
var JQuerySlide = React.createClass({
componentWillEnter: function(callback){
var $el = $(this.getDOMNode())
$el.slideDown(function(){
callback();
});
},
componentWillLeave: function(callback){
var $el = $(this.getDOMNode());
$el.slideUp(function(){
@spoike
spoike / webapi_example.js
Last active May 12, 2017 13:37
Simple WebAPI example
var PostsApi = require('webapi/posts'),
// assuming the api object from the jsbin snippet
Reflux = require('reflux');
var PostActions = createActions(["load", "loadError"]);
// load action is invoked either from:
// * top most component's componentDidMount
// function in your application, or
// * window.onLoad
// I prefer the first strategy because that'll
@sikanhe
sikanhe / improved_cache.js
Last active November 20, 2017 21:45
Most efficient way to store domain state in Redux (Indexed Key-Value Store)
//After working on the backend for a while, I started to continue working on my front end,
//I revisited my redux “cache” store and I made this improvement that made my life a lot easier.
//In my project for example, some collections i need to get the document by id, some by slug, some by username, and etc.
//If I need to account for those cases I had to make new action creators/types, for different entities.
//This is very frustrating as it makes the code less dry and leads to more boilerplate.
//Then what I realized was, I can just pass a “index” option for my insert action creators!(which defaults to “id")
//Actions
@xmlking
xmlking / Enum.es6.js
Last active June 25, 2019 18:09
JavaScript Enums with ES6, Type Checking and Immutability
export class EnumSymbol {
sym = Symbol.for(name);
value: number;
description: string;
constructor(name: string, {value, description}) {
if(!Object.is(value, undefined)) this.value = value;
if(description) this.description = description;
@joshrieken
joshrieken / Gulpfile.js
Last active July 10, 2019 15:33
Replacing Brunch with Gulp in Phoenix
// Contains support for: SASS/SCSS, concatenation, and minification for JS and CSS
var gulp = require('gulp');
var sass = require('gulp-ruby-sass');
var concat = require('gulp-concat');
var compress = require('gulp-yuicompressor');
@bruce
bruce / absinthe.md
Last active November 2, 2019 16:03
Very brief description of how Absinthe processes GraphQL
@spoike
spoike / reflux.js
Created June 29, 2014 22:23
A simpler implementation of React.JS's Flux
var EventEmitter = require('events').EventEmitter,
_ = require('lodash');
/**
* Creates an action functor object
*/
exports.createAction = function() {
var action = new EventEmitter(),
eventLabel = "action",