Skip to content

Instantly share code, notes, and snippets.

View mrboli's full-sized avatar

Bo Li mrboli

  • Toronto, ON
View GitHub Profile
@mrboli
mrboli / map-linked-list.js
Created January 10, 2019 01:44
Map fn for Linked Lists
// function Node(data, next = null) {
// this.data = data;
// this.next = next;
// }
function map(head, fn) {
if (!head) return null; // Just return bad nodes
const mappedHead = new Node(fn(head.data));
let lastMappedNode = mappedHead;
function chain(fns) {
let c = {};
let toEx = [];
for (let fn in fns) {
this[fn] = fns[fn];
c.[fn] = function () {
toEx.push({ [fn]: arguments });
}
}
@mrboli
mrboli / .tmux.conf
Last active October 14, 2016 21:28
dotfiles
# Plugins
run-shell ~/Dev/opensource/tmux-resurrect/resurrect.tmux
run-shell ~/Dev/opensource/tmux-continuum/continuum.tmux
set -g @resurrect-strategy-vim 'session'
set -g @continuum-restore 'on'
setw -g mode-keys vi
bind -n C-k send-keys -R \; clear-history
@mrboli
mrboli / async-food-order.js
Last active June 4, 2016 03:00
Callback Example for Erin Kim
// Async
function giveOrderToChef(giveFoodToCustomer){
var food = makeFood();
giveFoodToCustomer(food);
}
function callbackFunction(food) {
goToKitchen(food);
grabFood(food);
bringFoodToCustomer(food)
class Business < ActiveRecord::Base
include SubuserExtender
# ...
end
@mrboli
mrboli / unsub.js
Created March 2, 2016 23:24
Unsubscribe to Meetups on meetup.com
$('input.j-checkbox').each(function(){
if ($(this).attr('checked')) {
$(this).next().trigger('click');
}
});
$('.j-selectbox').val('NO_RECEIVE');