Skip to content

Instantly share code, notes, and snippets.

View samuelsimoes's full-sized avatar

Samuel Simões samuelsimoes

  • Appolus
  • Rio de Janeiro
View GitHub Profile
const Random = require('random-js')
const random = new Random(Random.engines.mt19937().autoSeed())
const SocketIO = require('socket.io-client')
const diffApplier = require('../frontEnd/js/diffApplier')
require('../backEnd/database')
const ModelMTTPlayer = require('../backEnd/models/mtt/player')
// const HOST = 'https://localhost:3000'
diff --git a/src/manifest.json b/src/manifest.json
index 75bf42f..b35588d 100644
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -12,5 +12,11 @@
"128": "icon-128.png"
},
"manifest_version": 2,
- "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
+ "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
layout title date categories
post
More simple Facebook Flux
2016-02-01 10:00
javascript

You probably are seeing the exponential growth of Facebook Flux pattern and its derivations. The main idea of Flux pattern is the one way data flow on the app and the clearly separated concerns layers.

Flux pattern defines three important layers on your app. The presentation layer that presents the app state, the store layer that hold the state itself and make the states mutations and the action creator layer that dispatches commands that are intercepted by stores through the fourth Flux's piece, the dispatcher. The diagram above show the flow:

@samuelsimoes
samuelsimoes / count_array_items.sql
Created November 21, 2015 18:20
This function returns a JSON with the array's item ocurrence counting. It only works on Postgres >= 9.4
create function count_elements(text[]) returns json as $body$
select
json_object_agg(key, value)
from (
select
item as key,
count(*) as value
from (select unnest($1) item) as item
group by item
) agg;
@samuelsimoes
samuelsimoes / bootstrap_2_field.js
Last active August 29, 2015 14:11
Some Handlebars helpers
Handlebars.registerHelper("bootstrapField", function(context, options) {
optionsHash = options.hash;
var markup = "<div class='control-group " + (optionsHash.containerClass || "") + "'>",
attrs = _.omit(optionsHash, ["containerClass", "label", "required", "helpText"]);
markup += "<label class='control-label";
if (optionsHash.required) {
markup += " required";
window.Person = {
warnChangeInAttribute: function(attribute, pastValue, value) {
console.log(attribute + " changed from " + pastValue + " to " + value);
}
};
Object.defineProperty(window.Person, "name", {
get: function() {
return this.nameValue;
},
// "{0} isso é um {1}".format('Olar', 'teste')
if (!String.prototype.format) {
String.prototype.format = function() {
var args = Array.prototype.slice.call(arguments);
return this.replace(/{(\d+)}/g, function(match, number) {
return (args[number] ? args[number] : match);
});
};
}
<!-- directive that make the partial inclusion -->
<div ng-include src="my_template.html"></div>
<!-- my_template.html -->
<div ng-controller="MyController" class="my-container">
<strong>My template</strong>
</div>
<!-- ---- -->
<!-- or -->
@samuelsimoes
samuelsimoes / collection_base.js
Last active June 14, 2016 17:24
Tiny Angular.js module to bring some Backbone.js collection/model structure. NON TESTED IN IE!
/*
* ModelCollection behavior for Angular.js
* Version 0.0.3
*/
angular.module("ModelCollection", []).factory("ExtendMethod", function () {
return function (props) {
var that = this,
child = function () { return that.apply(this, arguments); };
angular.extend(child, this);
@samuelsimoes
samuelsimoes / 0_reuse_code.js
Created May 20, 2014 15:41
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console