Skip to content

Instantly share code, notes, and snippets.

View kounelios13's full-sized avatar

Manos Kounelakis kounelios13

View GitHub Profile
@megahertz
megahertz / mongo-url.sh
Created February 28, 2018 04:10
Parse MongoDB connection string in bash
#!/usr/bin/env bash
set -e
# Usage: parse_mongo_url URL
# It sets the following variables:
# MONGO_HOST
# MONGO_PORT
# MONGO_DATABASE
# MONGO_USER
# MONGO_PASSWORD
var max = 100000000
console.time('empty loop')
function loop () {
for (var i = 0; i < max; i++) {}
}
loop()
@sofaking
sofaking / adb.sh
Created March 3, 2017 10:48
Get battery level via adb
adb shell dumpsys battery | grep level
#!/bin/sh
#
# Automatically add branch name and branch description to every commit message except merge commit.
#
COMMIT_EDITMSG=$1
addBranchName() {
NAME=$(git branch | grep '*' | sed 's/* //')
DESCRIPTION=$(git config branch."$NAME".description)
@rasmuschristensen
rasmuschristensen / BootboxJSCustomWidth
Created March 4, 2016 10:10
Changing the width of bootbox dialog
// css
.dialogWide > .modal-dialog {
width: 80% !important;
}
// script
bootbox.dialog({
className: "dialogWide",
title: "Foo",
message: "what to say, go wide",
buttons: {
@pirate
pirate / parseURLParameters.js
Last active December 15, 2023 07:17
Parse URL query parameters in ES6
function getUrlParams(search) {
const hashes = search.slice(search.indexOf('?') + 1).split('&')
const params = {}
hashes.map(hash => {
const [key, val] = hash.split('=')
params[key] = decodeURIComponent(val)
})
return params
}
@J2TEAM
J2TEAM / sublime-text-scopes.md
Last active January 17, 2024 22:44 — forked from iambibhas/scopes.txt
Sublime Text 2/3: Snippet scopes

Here is a list of scopes to use in Sublime Text 2/3 snippets -

ActionScript: source.actionscript.2
AppleScript: source.applescript
ASP: source.asp
Batch FIle: source.dosbatch
C#: source.cs
C++: source.c++
Clojure: source.clojure
@novadev94
novadev94 / memoization.py
Last active October 23, 2016 15:22
Dynamic Programming Memoization in Python
import functools
def memoization(mem_dict):
""" This is a version for modules' functions.
:Parameter - `mem_dict`
A global variable used to store the calculation result
:Usage
fibo_dict = {}
@memoization(fibo_dict)
@kyle-ilantzis
kyle-ilantzis / open-w-atom.reg
Last active June 1, 2021 17:20
Adds 'Open in Atom' to context menu in Windows Explorer.
Windows Registry Editor Version 5.00
;
; Adds 'Open in Atom' to context menu (when you right click) in Windows Explorer.
;
; Based on https://github.com/Zren/atom-windows-context-menu. It didn't work
; https://github.com/Zren/atom-windows-context-menu/issues/1.
;
; Save this file to disk with a .reg extension. Replace C:\\Atom\\atom.exe with
; the path to the atom executable on your machine.
@cuth
cuth / debug-scroll.md
Last active July 20, 2024 17:22
Find the elements that are causing a horizontal scroll. Based on http://css-tricks.com/findingfixing-unintended-body-overflow/

Debug Horizontal Scroll

(function (d) {
    var w = d.documentElement.offsetWidth,
        t = d.createTreeWalker(d.body, NodeFilter.SHOW_ELEMENT),
        b;
    while (t.nextNode()) {
        b = t.currentNode.getBoundingClientRect();
 if (b.right &gt; w || b.left &lt; 0) {