Skip to content

Instantly share code, notes, and snippets.

View joseconstela's full-sized avatar
🏠

Jose Constela joseconstela

🏠
View GitHub Profile
@joseconstela
joseconstela / env-setup.sh
Last active December 3, 2017 16:29
My development environment and machine setup. See my dotfiles at https://github.com/joseconstela/dotfiles
################################################################################
## OSX customisations
################################################################################
# Map CAPS key to esc. - https://stackoverflow.com/a/40254864
# Allow repeated keys
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
# Time until key repetition
defaults write -g InitialKeyRepeat -int 10
@joseconstela
joseconstela / meteorapp.conf
Last active June 29, 2016 10:43
MeteorJS application upstart service config file example, as shown at http://joseconstela.com/nginx-config-files-for-production-ready-meteorjs-apps/
# upstart service file at /etc/init/meteorapp.conf
description "Meteor.js application"
author "Jose Constela <[email protected]>"
# When to start the service
start on started mongod and runlevel [2345]
# When to stop the service
stop on shutdown
server_tokens off; # for security-by-obscurity: stop displaying nginx version
# this section is needed to proxy web-socket connections
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
@joseconstela
joseconstela / actions.test.js
Created June 27, 2016 12:23
Mocha and chai testing for MeteorJS - this is an example for http://joseconstela.com/continuous-integration-with-meteorjs-and-travis
require('./actions');
describe( 'actions tests', () => {
it( 'dilbert', () => {
var actionResult = actions['dilbert']();
assert.typeOf( actionResult, 'object' );
assert.typeOf( actionResult.display, 'object' );
assert.typeOf( actionResult.display.title, 'string' );
assert.typeOf( actionResult.display.link, 'string' );
assert.typeOf( actionResult.display.html, 'string' );
@joseconstela
joseconstela / .travis.yml
Created June 27, 2016 12:32
Travis config file for meteorjs applications - Example for http://joseconstela.com/continuous-integration-with-meteorjs-and-travis
language: node_js
node_js:
- '0.10'
sudo: required
before_install:
- curl https://install.meteor.com | /bin/sh
script: meteor test --once --driver-package dispatch:mocha-phantomjs
@joseconstela
joseconstela / tsp.js
Created June 29, 2016 10:51
TPS genetic algorithm in plain-javascript - to be used with acio-js
/*
* 0.0.1 - 29.06.16
* Experimental.
*
* Original code: https://github.com/parano/GeneticAlgorithm-TSP
*/
Array.prototype.clone = function() { return this.slice(0); }
Array.prototype.shuffle = function() {
for(var j, x, i = this.length-1; i; j = randomNumber(i), x = this[--i], this[i] = this[j], this[j] = x);
@joseconstela
joseconstela / hosts
Last active August 8, 2024 06:11
Prevent OSX calling home
################################################################################
# Prevent OSX calling home #
# #
# Mix of different /etc/hosts files found over internet, and calls filtered #
# using LittleSnitch for months. #
# #
# OSX sends a huge amount of requests to Cuppertino, even when you don't use #
# Spotlight suggestions, iCloud, updates and other services. Even if they are #
# disabled. #
# #
@joseconstela
joseconstela / index.js
Created August 16, 2016 23:22
kafka-node-basic-example
"use strict"
let kafka = require('kafka-node'),
HighLevelProducer = kafka.HighLevelProducer,
client = new kafka.Client('localhost:2181/'),
producer = new HighLevelProducer(client)
// In this demo, topics are intended to be created already.
// See kafka docs (or check https://hub.docker.com/r/wurstmeister/kafka/ =>
// "Automatically create topics")
AT+RST
OK
WIFI DISCONNECT
ets J`n 8 2013,rst cause:2, boot mode:(3,6)
load 0x40100000,,tail 0
chkstm 0x63
@joseconstela
joseconstela / Crop composition addon for MeteorJS collections
Created March 4, 2017 14:33
Tiempo de siembra - crop composition addon for MeteorJS collections
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// COMPOSITION
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
composition: {
type: Object,
label: 'Composición (cada 100gr)',
optional: true
},