Skip to content

Instantly share code, notes, and snippets.

@gamesguru
gamesguru / khaled-amazon-reading-book-chapters.cpp
Last active April 16, 2024 01:39
Solution to reading a book of chapters within given number of days
#include <bits/stdc++.h>
using namespace std;
int solution(vector<int> arr, int days_til_exam) {
// number of chapters
int n_chaps = arr.size();
// longest chapter
int m = *max_element(arr.begin(), arr.end());
@gamesguru
gamesguru / rsync.sh
Last active April 7, 2022 02:49
Shell script for neatly dry running and archiving rsync src and dest media
#!/bin/bash
cd "$(dirname "$0")"
rsync_cmd="rsync --archive --verbose"
# Determine if `--dry-run`
real=0
for var in "$@"
@gamesguru
gamesguru / .screenrc
Created March 17, 2022 18:15
From Chris
defshell -bash
hardstatus alwayslastline
hardstatus string '%{= kw}%-w%{= BW}%50>%n %t%{= kw}%+w%<'
shelltitle ""
multiuser off
vbell_msg "Beep!"
startup_message off
defscrollback 40000
#terminfo and termcap for nice 256 color terminal
# allow bold colors - necessary for some reason
@gamesguru
gamesguru / .vimrc
Created March 5, 2021 19:56
vim config
syntax on
@gamesguru
gamesguru / .bash_profile
Created March 5, 2021 19:53
bash profile (macOS)
[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"
[[ -r "/usr/local/etc/bash_completion.d/python-argcomplete" ]] && . "/usr/local/etc/bash_completion.d/python-argcomplete"
_ssh()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts=$(grep '^Host' ~/.ssh/config ~/.ssh/config.d/* 2>/dev/null | grep -v '[?*]' | cut -d ' ' -f 2-)
@gamesguru
gamesguru / .zprofile
Created March 5, 2021 19:52
zsh profile
# autoload -Uz compinit
# compinit
# [[ -r "/usr/local/etc/bash_completion.d/python-argcomplete" ]] && . "/usr/local/etc/bash_completion.d/python-argcomplete"
# eval "$(register-python-argcomplete /Users/shane/nutra/cli/nutra)"
alias grep='ggrep --color'
export GPG_TTY=$(tty)
@gamesguru
gamesguru / .zshrc
Created March 5, 2021 17:28
zsh rc file
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/Users/shane/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
@gamesguru
gamesguru / sol.py
Created January 15, 2021 18:19
Python printing: family-tree
class Node:
def __init__(self, parent_id, id, name):
self.id = id
self.parent_id = parent_id
self.name = name
self.children = []
def printChildren(node, level=1):
for c in node.children:
.headers on
.mode column
PRAGMA foreign_keys = 1;
@gamesguru
gamesguru / startup-shortcuts.sh
Last active March 17, 2022 18:14
xinput configurations for home desktop setup
#!/bin/bash
# # compx Left Hand
# xinput set-prop "pointer:Compx 2.4G Receiver Mouse" 322 1
# logitech Left Hand
xinput set-prop "Logitech USB Trackball" 328 1
# logitech Scroll Enabled
xinput set-prop "Logitech USB Trackball" 317 0 0 1
# logitech Scroll Button