Skip to content

Instantly share code, notes, and snippets.

set autoindent
set indicator
set linenumbers
set tabsize 4
set tabstospaces
set trimblanks
include "/usr/share/nano/*.nanorc"
extendsyntax python tabgives " "
bind ^C copy main
@rgrwkmn
rgrwkmn / cache.js
Created January 28, 2016 16:54
Simple JS cache class. Use cache.get to get the value of a key from the cache and provide a function for getting what should be there if it doesn't exist yet or the cache has expired.
class Cache {
constructor() {
this.cache = {};
this.timeouts = {};
}
set(key, value, ttl) {
this.cache[key] = value;
if (ttl) {
// instead of using timeouts it could validate the ttl when `get` is called
// so the amount of timeouts doesn't get out of control
@rgrwkmn
rgrwkmn / vm-deploy-actions.txt
Created September 30, 2015 16:22
Potential VM Deployment Process Actions
First there would be optimistic update actions when posting the data to the backend service. These would be linked together by some process ID in meta data.
```
{ type: VM_POST, payload: vmDataOnClient }
{ type: VM_POST_ERROR, payload: someError }
{ type: VM_POST_SUCCESS, payload: vmDataFromServer }
```
Then streaming data would come from the web server with progress of the VM deployment on the hypervisor. These would be linked together by the VM ID, since the VM is the thing they have in common.
```
{ type: VM_DEPLOY_START, payload: vmId } // VM added to deployment progress store
@rgrwkmn
rgrwkmn / function.requirejs.php
Created November 12, 2013 19:35
A Smarty function for including RequireJS and AMD modules in an established (read: antiquated) PHP project. It doesn't make sense to add require into everything because only new functionality and iterative enhancements will be able to make use of it.
<?php
global $requirejsDeps;
$requirejsDeps = array();
function smarty_function_requirejs($params, &$smarty)
{
global $requirejsDeps;
// if finishing and something has been required, do it
@rgrwkmn
rgrwkmn / gist:7254857
Created October 31, 2013 18:48
Example composer.json to force composer to find vmwarephp classes.
{
"name": "my/example",
"description": "an example",
"license": "gpl",
"require": {
"vmwarephp/vmwarephp": "dev-master"
},
"autoload": {
"classmap": [
"vendor/vmwarephp/vmwarephp/library"
@rgrwkmn
rgrwkmn / spinner.js
Last active December 25, 2015 07:19
Text spinner in JS. Call spin() to get the next character in the spin cycle.
var spin = function() {
var s = '|/-\\';
if (isNaN(this.i) || ++this.i > s.length - 1) {
this.i = 0;
}
return s[this.i];
}
@rgrwkmn
rgrwkmn / twitter-stream.js
Created September 24, 2013 21:26
Node script using ntwitter and cli-color to log streaming tweets into your terminal. Enter your own API keys and secrets, npm install ntwitter cli-color; node twitter-stream.js;
var twitter = require('ntwitter');
var clc = require('cli-color');
var twit = new twitter({
consumer_key: 'key',
consumer_secret: 'secret',
access_token_key: 'key',
access_token_secret: 'secret'
});