Skip to content

Instantly share code, notes, and snippets.

"atom-beautify":
prettyName: "Atom Beautify"
homepage: "https:/atom.io/packages/atom-beautify"
"atom-monokai":
prettyName: "Atom Monokai"
homepage: "https:/atom.io/packages/atom-monokai"
"atom-ternjs":
prettyName: "Atom Ternjs"
homepage: "https:/atom.io/packages/atom-ternjs"
"auto-detect-indentation":
@Zetaphor
Zetaphor / window-cookie.js
Created August 15, 2016 18:56
Window Cookie Object
const regex = /^(?:https?:\/\/w*\.?)?([a-zA-Z0-9\.\-_]+)(?:[\/.\-_a-zA-Z0-9]*)$/;
const str = `https://test.google.com/testdsadsa`;
let m;
if ((m = regex.exec(str)) !== null) {
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
# i3status configuration file.
# see "man i3status" for documentation.
# It is important that this file is edited as UTF-8.
# The following line should contain a sharp s:
# ß
# If the above line is not correctly displayed, fix your editor first!
general {
interval = 5
@Zetaphor
Zetaphor / mergeDicts.py
Last active September 9, 2017 00:29
Merge Dictionaries
def merge_dicts(*dict_args):
"""
Given any number of dicts, shallow copy and merge into a new dict,
precedence goes to key value pairs in latter dicts.
This function will work in Python 2 and 3 for all dicts.
e.g. given dicts a to g: z = merge_dicts(a, b, c, d, e, f, g)
Key value pairs in g will take precedence over dicts a to f, and so on.
https://stackoverflow.com/questions/38987/how-to-merge-two-dictionaries-in-a-single-expression
"""
result = {}
@Zetaphor
Zetaphor / apt-install.sh
Created September 16, 2017 21:09
Apt install from file
apt-get install $(grep -vE "^\s*#" apt-requirements.txt | tr "\n" " ")
@Zetaphor
Zetaphor / demoCode.html
Created October 16, 2017 18:02
Format byte string to human readable label
// ** Demo code **
var p = document.querySelector('p'),
input = document.querySelector('input');
function setText(v){
p.innerHTML = formatBytes(v);
}
// bind 'input' event
input.addEventListener('input', function(){
setText( this.value )
@Zetaphor
Zetaphor / console.debugMode.js
Created October 27, 2017 15:37
Console.log debugMode mute toggle
let origLog = window.console.log
window.console.debugMode = true
window.console.log = function () {
if (!window.console.debugMode) return
for (let i = 0; i < arguments.length; i++) {
origLog(arguments[i])
}
}
console.log({dsa: 1}, 'dsadsa', 12321)
@Zetaphor
Zetaphor / random-string.js
Created April 30, 2018 17:39
Javascript Random String
Math.random().toString(36).split('0.')[1]
@Zetaphor
Zetaphor / pre-commit
Created May 1, 2018 16:48 — forked from hraban/pre-commit.md
Git pre-commit hook (.git/hooks/pre-commit) to prevent accidentally committing debug code (add NOCOMMIT in source comment)
#!/bin/sh
# This pre-commit hook will prevent you from committing any line (or filename) containing
# the string NOCOMMIT. Use that tag in comments around source code you want to avoid
# accidentally committing, like temporary IP addresses or debug printfs.
#
# To add it to an existing repository, save it to .git/hooks/pre-commit (or append, if
# that file already exists). Remember to make executable (chmod +x ...)
#
# To automatically add this pre-commit hook to every repository you create or clone: