Skip to content

Instantly share code, notes, and snippets.

@tswaters
tswaters / gist:d26036395341f5fdc17d
Last active August 29, 2015 14:04
Bind ctrl+shift+alt f1-12 to output various macros files
; bind ctrl+shift+alt f1-12 to output various macros files
Loop 12
{
Hotkey, ^!+f%A_Index%, OutputMacroFile
}
return
OutputMacroFile:
key := RegExReplace(A_thisHotkey, "[+!^]", "")
FileRead, Contents, %AppData%\macros\%key%.txt
@tswaters
tswaters / ajax-helper.js
Last active August 29, 2015 14:23
ajax helper
function ajax (opts) {
if (this instanceof ajax) throw new Error("stop instantiating me!");
if (!opts) throw new Error("pass opts, dummy.")
if (!opts.url) throw new Error("pass url, dummy");
if (!opts.method) throw new Error("pass method, dummy");
var callbacks = {
success: [],
failure: [],
always: []
@tswaters
tswaters / angular-resolve.md
Created August 6, 2015 06:33
defer controller initialization until after a $resolve function is resolved.

Not sure if this will at all come in handy, seems to me if the controller doesn't run it just won't show things. More of a starting point than anything else - without further ado, adding a $resolve function on a controller and have it resolve prior to controller initialization.

angular.module('resolve', [])
  .directive('resolveController', [
            '$controller', '$parse', '$injector', '$window',
    function($controller,   $parse,   $injector,   $window) {
      return {
        link: function(scope, elem, attrs) {
          var ctrlName = attrs.resolveController;

setting up nodejs debugging on debian

$ npm insall -g node-inspector

$ node-inspector 
Node Inspector v0.12.2
Visit http://127.0.0.1:8080/?ws=127.0.0.1:8080&port=5858 to start debugging.
function transformAttributes (stats) {
attrs = parseInt(attrs, 8);
var others = attrs & 7;
var user = attrs >> 3 & 7;
var owner = attrs >> 6 & 7;
return [
owner & 4 ? 'r' : '-',
owner & 2 ? 'w' : '-',
owner & 1 ? 'x' : '-',
@tswaters
tswaters / math-client.log
Created April 21, 2016 16:13
Seneca errors using math client/service
2016-04-21T16:07:40.563Z 6ti4fu88u7oq/1461254860543/16252/- INFO hello Seneca/2.0.0/6ti4fu88u7oq/1461254860543/16252/-
2016-04-21T16:07:40.581Z 6ti4fu88u7oq/1461254860543/16252/- DEBUG options { log: { map: [ { level: 'all', handler: { [Function: print] routestr: '{ level: \'fatal\' }' } } ] }, tag: '-', idlen: 12, timeout: 11111, default_plugins: { basic: true, cluster: true, 'mem-store': true, repl: true, transport: true, web: true }, debug: { fragile: false, undead: false, print: { options: false }, act_caller: false, short_logs: false, callpoint: false }, strict: { result: true, fixedargs: true, add: false, find: true, maxloop: 11 }, actcache: { active: true, size: 11111 }, trace: { act: false, stack: false, unknown: 'warn' }, stats: { size: 1024, interval: 60000, running: false }, deathdelay: 11111, admin: { local: false, prefix: '/admin' }, plugin: {}, internal: { close_s
@tswaters
tswaters / index.js
Last active April 6, 2017 20:42
translating a provided date to a given timezone with moment-timezone
var moment = require('moment-timezone')
console.log(midnightPst('2017-12-31T13:59:59.999Z')) // provided as 11:59 HAST
console.log(midnightPst('2018-01-01T07:59:59.999Z')) // provided as 11:59 PST
console.log(midnightPst('2018-01-01T04:59:59.999Z')) // provided as 11:59 EST
console.log(midnightPst('2018-12-31T23:59:59.999Z')) // provided as 11:59 UTC
// east of GMT doesn't work.
console.log(midnightPst('2018-01-01T08:59:59.999Z')) // provided as 11:59 JST
@tswaters
tswaters / browserify-virtual-file.md
Created September 5, 2016 02:05
Trying to mimic virtual files in browserify

Let's say you have a string that you want to include in browserify. This needs to be identified by a path so you can require it later, but a file does not exist at that path's location.

You can pass streams to browserify, and streams can include arbitrary strings... the key is ignoreMissing:true which will dutifully ignore any required files that aren't actually on the file system.

Now, for it to actually come through as something you can require, it needs to be exposed as an explicit string. While this works, it means you can only reference it by this name... see with-expose.js

The main problem of course is that mechanisms for directory loading won't work like they do in a normal commonjs fashion.

i.e., consider the following was used for ./requires:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\tyler\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'un',
1 verbose cli 'lodash' ]
2 info using npm@5.3.0
3 info using node@v8.2.1
4 verbose npm-session 183b62c0437ca1ee
5 silly install loadCurrentTree
6 silly install readLocalPackageData
@tswaters
tswaters / instructions.md
Last active November 29, 2017 02:54
Using Seneca-Web with request$ and response$

Using Seneca-Web with request$ and response$

node web-host.js

In another terminal

node web-client.js