Skip to content

Instantly share code, notes, and snippets.

@menixator
menixator / README.md
Last active October 10, 2023 05:50
A little script to fix download names over at the ahk forums

AHK Forum: Better Download Names

This userscript allows you to customize how the files downloaded from the codeboxes over at the autohotkey forum are named. By default they will all be named Untilted.ahk

There are currently two versions of the script:

#include "MicroBit.h"
#include <vector>
using namespace std;
#define MAX_X 5
#define MAX_Y 2
#define MAX_HEIGHT 3
#define MAX_COUNT 5
#include "MicroBit.h"
MicroBit uBit;
bool started = false;
bool isSender = false;
int whatToSend = 0;
void onButtonA(MicroBitEvent event) {
alias wanip='dig +short myip.opendns.com @resolver1.opendns.com'
alias lanip='_lanip | column -t'
function _lanip(){
for dev in $(ls /sys/class/net); do
echo -n $dev " "
net=$(ip -f inet addr show $dev | grep --color=never -Po 'inet \K[\d.]+?\/\d+')
if [[ -n $net ]]; then
echo -n $net
else
@menixator
menixator / Backbone.localStorage.md
Last active September 28, 2016 11:43
Modifying the Backbone.localStorage adapter to accomodate special characters(eg: commas) in it's keys

Modifying the Backbone.localStorage adapter to accomodate special characters(eg: commas) in it's keys

Backbone.localStorage is for the most part, working without any problems.

It allows the user to assign a name to the storage instance, stores the model ids in the localStorage as a comma seperated string with the name as the key.

If the models don't have any ids they're awarded one by the adapter itself. Such ids take the format of a GUID.

The problem arises when one of the model ids contain a comma.

@menixator
menixator / terminal.sh
Created August 6, 2016 18:38
Make global terminal shortcut work for sublime text
#!/usr/bin/env zsh
# Download this script
# Save it somewhere. Make it an executable with
# $ chmod +x terminal.zsh
# Then add a systemwide shortcut for this script
# and you're done!
# Get the current window id
ACTIVE=$(xdotool getactivewindow)
# Find all the sublime text windows that are open.
@menixator
menixator / ms.js
Created July 21, 2016 19:15
A tiny utility to convert milliseconds into a human readable format.
// Constants.
var s = 1000;
var m = s * 60;
var h = m * 60;
var d = h * 24;
var y = d * 365.25;
// Specify the minimum a unit can be before
// `ms()` adds it to the output.
@menixator
menixator / FindDependencies.js
Created December 26, 2014 16:57
Code snippet to find the dependencies of a CoffeeScript file.
// Finding all the require calls in coffee-script file.
// This won't work if a minified version of coffeescript is loaded.(Like @ http://coffeescript.org)
// Note that if the argument to require should be a string. `module = 'fs'\nfs = require(module)` wont work.
var CoffeeScript = require('coffee-script');
// There are two requires calls.
var code = 'fs = require \'fs\'\nEventEmitter = require(\'events\').EventEmitter';
var program = CoffeeScript.nodes(code);
@menixator
menixator / youtube-loop.md
Last active August 29, 2015 14:08
Looping videos on youtube

Just open up the developer tools and run:

document.querySelector('video').loop = true;

UPDATE:

Just right click twice with the cursor in the same position twice. You'll see the default context menu. Select loop from it.

@menixator
menixator / EventEmitter.js
Last active August 29, 2015 14:08
Yet another EventEmitter library
var EventEmitter = (function() {
EventEmitter.name = 'EventEmitter';
function EventEmitter() {}
/**
* Event listener storage array.
* @type {Array}
*/
EventEmitter.prototype.__events__ = [];