Skip to content

Instantly share code, notes, and snippets.

View hsribei's full-sized avatar

Helder S Ribeiro hsribei

View GitHub Profile
@mpereira
mpereira / gist:3072187
Created July 8, 2012 18:26
A little help to stop unconsciously checking distracting web sites.
alias focus="sudo sh -c \"echo '127.0.0.1 www.facebook.com twitter.com mail.google.com # aab6de513ab5de9359809f3cdb62d352' >> /etc/hosts\""
alias unfocus='sudo sed -i "" "/aab6de513ab5de9359809f3cdb62d352/d" /etc/hosts'
@nelix
nelix / background.js
Created October 25, 2012 05:21
Chrome extension which reloads all unpacked extensions on opening of a url, for use with gruntjs's watch task.
/*
* Use with grunt-exec command: 'open -a "/Applications/Google Chrome.app" file://localhost/reload'
*/
chrome.webRequest.onBeforeRequest.addListener(hook, {urls: ['file://localhost/reload*']});
function hook(details) {
console.log('reloading all dev extensions');
chrome.management.getAll(function(extensions){
for(var i in extensions){
extension = extensions[i];
try {
function foo() {
foo();
}
foo();
} catch(e) {
window.location.href="http://stackoverflow.com/search?q=[js]+" + e.message || e;
}
@radzserg
radzserg / meteor pagination class
Last active October 19, 2016 20:34
meteor pagination class
namespace('App.data')
###
Meteor pagination class
Usage
UsersController = RouteController.extend
waitOn: ->
@page = @params.query.page || 1
@pagination = new App.data.Pagination(Users, selector, {page: @page})
@prestonparris
prestonparris / reactjs-conf-2015-notes.md
Last active April 6, 2017 21:32
Notes from the 2015 React.js Conference

Reactjs conf 2015 Notes

  • react native announced

    • Allows you to use react style javascript to target native ios and android, native views, live reloading
    • intro pt1
    • intro pt2
    • facebook groups app uses react native with graphql and relay
  • realtime page tweaking

    • rethink best practices and workflows
  • inmutability is a good idea

@yoshuawuyts
yoshuawuyts / ssb.rs
Last active May 16, 2017 16:47
Rough rust translation of the https://github.com/ssbc/secure-scuttlebutt example
extern crate ssb_keys;
extern crate ssb;
extern crate mio;
#[macro_use]
extern crate pull;
const pathToSecret: String = "/tmp/ssb1-secret";
const pathToDB: String = "/tmp/ssb1/";
@carlosmaniero
carlosmaniero / Elm.hs
Last active October 30, 2017 13:19
Elm architecture in Haskell: A study case
data Model = Model
{ name :: String
, gender :: String
, loading :: Bool
, homeworld :: String
} deriving (Show)
data PersonResponse = PersonResponse
{ personName :: String

Someone in the Elm slack channel threw out this idea of naming Msg in the past tense, and not imperatively. I thought it was an interesting idea and I adopted the practice, just to try it out. I forgot who it was, I wish I could give them credit.

Anyway, the ramifications were more than I expected, and not simply the same Msg with different names. What I started doing is naming Msg as if they were saying "This happened". So where I would say "HandleUsernameField" I might instead say "UsernameFieldChanged" or instead of "Close" I would do "XClicked". What I didnt account for was that Msg and functionality dont map one to one. So for example, if you have a Msg named Navigate, its going to be the one Msg you use whenever you want to navigate. But if you are naming Msg as paste-tense descriptions, then several different things could happen that could cause a navigation. Since many things should cause a navigation, naming Msg in the past tense leads to lots of Msg which do the same thing.

@IronSavior
IronSavior / to-function.js
Created August 7, 2017 22:30
JavaScript named predicate helper (Symbol#to_proc from Ruby)
"use strict";
// Make predicate funtions more convenient.
// Works like Ruby's Symbol#to_proc, which is usually called with the unary & operator and a Symbol literal:
// (ruby) %w[one two three].map(&:upcase) # returns ["ONE", "TWO", "THREE"]
// (js) ['one', 'two', 'three'].map(toFn('toUpperCase')); // returns ["ONE", "TWO", "THREE"]
// (js) ['one', 'two', 'three'].map(toFn`toUpperCase`); // same as above, but called via tagged string literal
// @param name {String} Name of method
// @param ...bound_args Arguments to bind NOTE: Args cannot be bound when calling as a tagged-template
// @return {Function} Function to call named method with bound args on any object given at time of invocation
module.exports = function toFn( name, ...bound_args ){
@ashblue
ashblue / nodejs-recursive-directory.js
Created October 19, 2012 05:06
NodeJS recursive directory listing without a module package
/**
* Goes through the given directory to return all files and folders recursively
* @author Ash Blue ash@blueashes.com
* @example getFilesRecursive('./folder/sub-folder');
* @requires Must include the file system module native to NodeJS, ex. var fs = require('fs');
* @param {string} folder Folder location to search through
* @returns {object} Nested tree of the found files
*/
// var fs = require('fs');
function getFilesRecursive (folder) {