Skip to content

Instantly share code, notes, and snippets.

View mkoryak's full-sized avatar
🐈
Working

Misha Koryak mkoryak

🐈
Working
View GitHub Profile
@mkoryak
mkoryak / moplogger.js
Created July 7, 2021 14:20 — forked from bathos/moplogger.js
moplogger.js
// This is useful for a few things:
//
// 1. Checking what dictionary options are supported by some platform API.
// 2. Debugging mysterious cases where an object you pass as input to another
// API doesn’t seem to get treated the way you’re expecting.
// 3. When designing another Proxy’s handler implementation, verifying that you
// are accounting for everything correctly and that the intended abstraction
// isn’t leaking in quirky ways.
//
// ex:
@mkoryak
mkoryak / git-deletebranches.sh
Last active December 6, 2016 19:44 — forked from bxt/git-deletebranches.sh
Git Delete Merged Branches
#!/bin/bash
MAIN=${1:-develop}
BRANCHES=$(git branch --merged $MAIN | grep -v -e 'master\|staging\|develop\|\*')
echo Branches merged into $MAIN:
echo $BRANCHES
read -p "Delete these branches (y/n)? " answer
@mkoryak
mkoryak / response_rewriter.coffee
Created October 14, 2015 19:34
rewrite responses
express = require("express")
fs = require('fs')
https = require('https')
httpProxy = require('http-proxy')
path = require('path')
# where do you want to see our stuff? site must use bootstrap 3!!
#HOST = "http://getbootstrap.com"
HOST = "https://hourlynerd.com"
// Safari, in Private Browsing Mode, looks like it supports localStorage but all calls to setItem
// throw QuotaExceededError. We're going to detect this and just silently drop any calls to setItem
// to avoid the entire page breaking, without having to do a check at each usage of Storage.
if (typeof localStorage === 'object') {
try {
localStorage.setItem('localStorage', 1);
localStorage.removeItem('localStorage');
} catch (e) {
Storage.prototype._setItem = Storage.prototype.setItem;
Storage.prototype.setItem = function() {};
circularIndex = (idx, len) ->
return ((idx % len) + len) % len
@mkoryak
mkoryak / wiredep_overrides_fix.js
Last active October 30, 2015 14:18
wiredep - respect child dependencies' bower overrides
/*
this hack fixes the following issues:
https://github.com/taptapship/wiredep/issues/149
https://github.com/taptapship/wiredep/issues/183
be aware that:
- this will take overrides from everything in your BOWER_PATH,
even packages that you might not depend on
- overrides in your bower.json win
@mkoryak
mkoryak / js_routes.html
Created December 4, 2014 19:30
use flask's url_for in javascript
{% autoescape false %}
(function(){
var ruleMap = {{ rule_map }};
X = X || {};
X.url_for = function(endpoint, params) {
var re = /\<\s*(\w+:)*(\w+)\s*\>/ig;
if (!params) {
params = {};
}
@mkoryak
mkoryak / dialog.coffee
Created September 26, 2014 15:15
bootstrap window.confirm() replacement, requires bootstrap3, jquery and underscore
##
# Open a confirmation dialog with 2 buttons (ok, cancel) and a question, and an optional title
#
# use: $modal = X.dialog({body: "Are you sure?", primary: "OK", secondary: "Cancel", title: null}, function(primaryClicked){
# var $button = this; // 'this' is the jquery obj of the button that was clicked
# }); //the function returns the modal that was just shown so that you can modify it
#
# arguments (square brackets around type means that it is optional):
# opts = [object]
# body = [string] (default: 'Are you sure?' ) - the body text of the dialog
@mkoryak
mkoryak / formatCurrency.js
Created September 24, 2014 20:14
currency format trick
"1234567890.34".replace(/\B(?=(\d{3})+(?!\d))/g, ",")
"1,234,567,890.34"
@mkoryak
mkoryak / op.user.js
Created August 18, 2014 23:18
OP login fix
// ==UserScript==
// @name Catman OpenPediatrics Login
// @namespace dogself
// @version 0.1
// @description log in like catman
// @include https://hq.app.openpediatrics.org/webUI
// @include https://hq.app.openpediatrics.org/webUI/
// @grant unsafeWindow
// @run-at document-end
// @copyright dogself