Skip to content

Instantly share code, notes, and snippets.

View metasansana's full-sized avatar
🕺
Wine on a buffer.

Lasana Murray metasansana

🕺
Wine on a buffer.
View GitHub Profile
@metasansana
metasansana / install_mongodb.sh
Last active February 28, 2023 16:59
Installs and starts mongodb on a github runner for tests.
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo systemctl daemon-reload
sudo systemctl start mongod
@metasansana
metasansana / debounce.js
Created September 2, 2017 22:32
Quick JavaScript/Typescript debounce function.
const debounce = (f, delay) => {
let timer = null;
return a=> {
if(!timer) {
timer = setTimeout(a=>f(a), delay);
}else{
@metasansana
metasansana / potoo.ts
Last active May 18, 2017 10:47
Attempt at actor model in typescript.
import { match } from 'afpl/lib/control/Match';
import { Suspend, Return, liftF } from 'afpl/lib/monad/Free';
import { Maybe, fromAny } from 'afpl/lib/monad/Maybe';
import { IO, safeIO, wrapIO } from 'afpl/lib/monad/IO';
import { Free } from 'afpl/lib/monad/Free';
import { Functor } from 'afpl/lib/data/Functor';
import { identity, compose } from 'afpl/lib/util';
import { SharedBuffer } from 'afpl/lib/async/SharedBuffer';
/**
@metasansana
metasansana / phpclosure
Created September 1, 2013 15:01
PHP closure.
function outer (int $outerArg) { //this could also be a custom type
return function (int $innerArg) { // closure function
return $outerArg+$innerArg;
}
<!-- Add the following lines to theme's html code right before </head> -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script>
<script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script>
<!--
Usage: just add <div class="gist">[gist URL]</div>
Example: <div class="gist">https://gist.github.com/1395926</div>
-->
@metasansana
metasansana / golangclosure
Created September 1, 2013 14:58
Go language closure.
func outer (outerArg int) func(int) { //this could also be a custom type
return func (innerArg int) int { // closure func
return outerArg+innerArg;
@metasansana
metasansana / jsclosure
Created September 1, 2013 14:54
Javascript closure
function outer (outerArg) {
return function (innerArg) { // closure function
return outerArg+innerArg;
};
@metasansana
metasansana / no-setters
Created July 2, 2013 22:00
No setters please (unless necessary).
//One of the popular concepts in OOP style programming is the concept of loose coupling.
//Your objects should have everything they need to carry out their duties from the time you instansiate them (new Object).
//Failing that, you should be able to inject any missing dependecies into your classes whenever necessary.
//This does not mean you go and create a whole bunch of setters.
//Wrong!
dog = new Animal();
dog.setColor('blue');