This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/node | |
const root = process.cwd() | |
const lockVersions = Object.fromEntries(Object.entries(require(`${root}/package-lock.json`).dependencies).map(([pkg, { version }]) => ([pkg, version]))) | |
const { dependencies, devDependencies } = require(`${root}/package.json`) | |
const installedDependencies = Object.fromEntries(Object.entries(dependencies || {}).map(([pkg, looseVersion]) => { | |
return [pkg, { version: looseVersion, installed: lockVersions[pkg] }] | |
}).filter(([_, { version, installed }]) => { | |
version = version.startsWith('^') ? version.split('^')[1] : version | |
return version !== installed | |
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from json import loads | |
from dataclasses import dataclass | |
@dataclass | |
class BaseObject: | |
@classmethod | |
def from_dict(cls, _dict): | |
entity = BaseObject() | |
entity.__dict__ = _dict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import inspect | |
def is_json_responder(responder_fn): | |
"""Helper function to check if a function is a JSON responder. Uses | |
inspect to get the source code and identifies the last line being a | |
jsonify call | |
""" | |
lines = [_ for _ in inspect.getsource(responder_fn).split("\n") if _] | |
return "jsonify({" in lines[-1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function() { Array.from(document.querySelectorAll('.s-result-item')).filter(el => el.innerText.indexOf('Currently not deliverable') !== -1).map((el) => el.parentElement.removeChild(el)); })() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function gstup() { | |
if [[ -z $1 ]]; then | |
echo -e "A subtree name is required" | |
return | |
fi | |
if [[ -z $2 ]]; then | |
echo -e "Subtree's branch name is required" | |
return | |
fi | |
# Stash local changes to prevent collisions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def j(lineno): | |
frame = sys._getframe().f_back | |
called_from = frame | |
def hook(frame, event, arg): | |
if event == 'line' and frame == called_from: | |
try: | |
frame.f_lineno = lineno |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias updateFromDev='git stash && git pull origin development --rebase && git stash pop' | |
function cd() { | |
builtin cd "$@" || return | |
if [[ -d .git ]] | |
then | |
updateFromDev | |
fi | |
} | |
# Adopted from https://unix.stackexchange.com/a/366923 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Utility script to set keyboard backlight level from command line. | |
# The kernel that ships with stock Ubuntu lacks the hardware support | |
# for certain devices like the keyboard backlight. | |
# Ref: [1], [2]. | |
# This script uses the tweak suggested here([3]) to set the background | |
# light levels. | |
# Caveat emptor: The script uses the max_brightness file in the device |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function getRemotes { | |
remotes=`git branch -r | grep -v HEAD` | |
local branches="" | |
for branch in $remotes; do | |
echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; | |
done | sort -r | head -n 1 | awk '{print $7}' | |
echo $branches | |
} |
NewerOlder