Skip to content

Instantly share code, notes, and snippets.

@tuvokki
tuvokki / install_rabbitmq_docker
Created April 30, 2018 06:20
Install RabbitMQ with Docker
docker run -d --hostname my-rabbit --name some-rabbit -p 15672:15672 -p 5672:5672 rabbitmq:3-management
iex(1)> lala = fn(msg) -> send self(), {:hello, msg} end
#Function<6.99386804/1 in :erl_eval.expr/5>
iex(2)> lala.("hehe")
{:hello, "hehe"}
iex(3)> lala.("hoho")
{:hello, "hoho"}
iex(4)> getst = fn() -> receive do {:hello, msg} -> "Got this #{inspect msg}" after 1_000 -> "Nothing after 1s" end end
#Function<20.99386804/0 in :erl_eval.expr/5>
iex(5)> getst.()
"Got this \"hehe\""
@tuvokki
tuvokki / vscode.settings.json
Last active March 24, 2017 15:22
A set of settings for VSCode
// Place your settings in this file to overwrite the default settings
{
"window.zoomLevel": 0,
"editor.tabSize": 2,
"editor.detectIndentation": false,
"editor.formatOnSave": true,
"editor.minimap.enabled": true,
"editor.minimap.renderCharacters": false,
"editor.cursorStyle": "underline-thin",
"editor.dragAndDrop": true,
@tuvokki
tuvokki / README.md
Created December 21, 2015 15:44 — forked from chriswessels/README.md
A guide to setting up self-hosted infrastructure for Meteor applications on Ubuntu Server 13.04.

#Meteor and Self-hosted Infrastructure

Meteor is an eye-opening JavaScript framework that runs on both the client and the server, giving developers a revolutionary take on software engineering. If you are not familiar with Meteor, I urge you to visit their website.

##An overview

In this brief gist, I am going to discuss the process of setting up a server (in my case, a VPS) to host Meteor applications.

My experience with Meteor has been brief, however it has not taken much demonstration for me to realise the significance of this stellar framework. Let's jump right in!

//See: http://stackoverflow.com/questions/15937267/inject-service-in-app-config
//See: http://stackoverflow.com/questions/14688290/inject-dependencies-in-run-method-of-the-module-in-angularjs
var app = angular.module('SystemSettings', ['ui.router', 'formly', 'formlyBootstrap']);
/**
* Set up routing
*/
app.config(function($stateProvider, $urlRouterProvider) {
// For any unmatched url, redirect to /main
@tuvokki
tuvokki / bcolors.py
Created June 30, 2015 11:18
Simple Python class to create colored messages for command line printing
# Helper class to print colored output
#
# To use code like this, you can do something like
#
# print bcolors.WARNING
# + "Warning: No active frommets remain. Continue?"
# + bcolors.ENDC
#
# you can also use the convenience method bcolors.colored like this
#

Add this to a bogart (or express etc.) route to do funky suff. See bogart-blog and just paste this in app.js.

router.get('/✌☮✔', function (req) {
  return 'Freedom and Peace = like!';
});

image

@tuvokki
tuvokki / test-data.js
Created February 9, 2015 20:52
Generate data for a blog with mongoskin
/**
* Run with: $ node test-data.js
*/
var mongoskin = require('mongoskin'),
http = require('http'),
db = mongoskin.db('mongodb://@localhost:27017/tuvok', {safe:true}),
coll = db.collection("posts"),
id,
titleDone = false,
/**
* This method will calculate the change in a player's
* Elo rating after playing a single game against another player.
* The value K is the maximum change in rating.
**/
function calculateELORatingChange(elo1, elo2, k)
{
var percentage = 1 / ( 1 + Math.pow( 10, (elo2 - elo1) / 400 ) );
return {
@tuvokki
tuvokki / gist:7080299
Created October 21, 2013 08:13
Script by Stijn
(function() {
var test, something;
function privateFunc() {
};
var myObject = {
myMethod: function() {privateFunc.apply(this, []);}
};