Skip to content

Instantly share code, notes, and snippets.

@thfrei
thfrei / CAcfp.js
Last active May 6, 2016 14:06
Communicative Act Library suggestion for eve agents: Contract Net Interaction Protocol (call for proposal)
// Suggestion for a communicatve act library for agent communication in Javascript.
// Initiator:
agent
.communication('cfp', 'initiator')
.recipient(adressOfResponder)
.cfp(function)
.onRefuse(function)
.onPropose(function)
.onFailure(function)
// http://stackoverflow.com/questions/12064040/javascript-what-is-the-best-method-when-creating-chainable-functions - Olegas
function test() {
// when test() is called as a regular function
// it's `this` will be `undefined` (in strict mode) or will refer to a global object
// when test() is called with `new` operator
// it's `this` will be an instance of `test` object
if(!(this instanceof test)) {
// create a new object
return new test();
"3.13.1 (created: 2016/05/04 01:34:00)
noremap e :emenu<Space>
noremap ge gT
noremap gr gt
noremap v :emenu<Space>Tools.Downloads<Return>
noremap xd :tabonly<Return>|:open<Space>about:blank<Return>
source! "C:\\Users\\windo\\_vimperatorrc.local"
" vim: set ft=vimperator:
@thfrei
thfrei / param serialize
Created January 6, 2017 10:45 — forked from yakirn/param serialize
A modified version of serialize and param methods from zeptos, that depends on _ as a global var (tested on [email protected])
/* the following serialize and param methods are a version of zepto's
* https://github.com/madrobby/zepto/blob/601372ac4e3f98d502c707bf841589fbc48a3a7d/src/ajax.js#L344-L370
* modified to use _ (tested on [email protected], should also work in underscore)
* to use with github's fetch:
fetch(urrl, {
method: 'post',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded'
}
@thfrei
thfrei / bootstrap-vertical-grid.css
Created January 27, 2017 09:44 — forked from metaist/bootstrap-vertical-grid.css
Bootstrap vertical grid. For laying out full-screen fixed height webapps.
.container-fixed {
bottom: 0;
position: fixed;
left: 0;
right: 0;
top: 0;
}
.container-fixed .col {
height: 100%;
@thfrei
thfrei / progressbar.html
Created February 3, 2017 12:09
Progress Bar with ticks
<!-- Source: http://codepen.io/anon/pen/egrGVL - Captain Anononymous -->
<div class="timeline-container">
<div class="timeline">
<!-- TIMELINE PROGRESS BAR OUTER STROKE -->
<div class="progress-timeline-border ">
<!-- TIMELINE PROGRESS BAR -->
<div class="progress-timeline">
<!-- CURRENT MILEAGE MARKER -->
<div class="timeline-marker" style="left: 125px">
<div class="timeline-current-mileage">
# Make vimium behave like vimperator@firefox
map d removeTab
map ge previousTab
map gr nextTab
map u restoreTab
# Use smooth scrolling
# Use the link's name and numbers for link-hint filtering
# Don't let pages steal the focus on load
@thfrei
thfrei / vimium-ff-extension-mapping
Created October 11, 2017 09:01
vimium-ff extension mappings, so that it feels more like vimperator
# Insert your preferred key mappings here.
map ge previousTab
map gr nextTab
map d removeTab
unmap yy
map y copyCurrentUrl
@thfrei
thfrei / userChrome.css
Last active January 14, 2024 18:55
userChrome.css Firefox FF57 - tree-style-tab, tridactyl, remove tabs in top bar title
/*
* Settings for Firefox using Treestyle-Tabs and Tridactyl
*
* 1) find userChrome.css in:
* Windows: %AppData%\Roaming\Mozilla\Firefox\Profiles\xyz.default-release\chrome\userChrome.css
* Linux: ~/snap/firefox/common/.mozilla/firefox/xyz.default/chrome
* Or go to: about:support => Profile Directory
* => If folder chrome does not exist, create!
* 2) Enable usage of userChrome.css in about:config
* Set toolkit.legacyUserProfileCustomizations.stylesheets to true
@thfrei
thfrei / prom-client_pm2_cluster.js
Created February 14, 2020 16:35 — forked from yekver/prom-client_pm2_cluster.js
Instead of `cluster` module there is no direct access to the master process in `pm2`. To return metrics for the whole cluster you can do IPC calls from the active instance to the rest of them and wait while all their locally collected metrics will be sent. Finally you have to aggregate all received metrics.
const prom = require('prom-client');
const pm2 = require('pm2');
let pm2Bus;
const REQ_TOPIC = 'get_prom_register';
function pm2exec(cmd, ...args) {
return new Promise((resolve, reject) => {
pm2[cmd](...args, (err, resp) => (err ? reject(err) : resolve(resp)));