Skip to content

Instantly share code, notes, and snippets.

View donchev7's full-sized avatar

Bobby Donchev donchev7

View GitHub Profile
Section "InputClass"
Identifier "libinput touchpad catchall"
MatchIsTouchpad "on"
MatchDevicePath "/dev/input/event*"
Driver "mtrack"
#Option "Ignore" "on"
Option "IgnorePalm" "true"
Option "TapButton1" "1"
Option "TapButton2" "3"
@donchev7
donchev7 / main.go
Last active January 24, 2022 13:40
go without if statements
package main
import (
fmt
)
func main() {
type fnType = func(a int, b int) int
fnMap := map[string]fnType{
"ADD": func(a int, b int) int {
#!/bin/bash
set -e
export distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | tee /etc/apt/sources.list.d/nvidia-docker.list
# Because of Microsoft not properly installing cuda :/
@donchev7
donchev7 / Move images between 2 Azure ACR registries
Created October 3, 2020 12:13
Move images between 2 Azure ACR registries
# Source ACR
repositories=$(az acr repository list -n <sourceACRName>)
for r in $repositories; do az acr repository show-manifests -n <sourceACRName> --repository $r ; done
cat response.json | jq -r '.[].tags[0]' | grep -v null | xargs -n 1 -I % sh -c "az acr import -n <sourceACRName> --source $REPO:% --image $REPO:% --registry <scopeId>"
#!/bin/bash
set -e
rm -rf /var/lib/apt/lists/*
apt-get update
apt-cache gencaches
apt-get install -y \
apt-transport-https \
ca-certificates \
@donchev7
donchev7 / ubuntu-install-az.sh
Created October 16, 2020 08:33
Install azure cli on ubuntu
#!/bin/bash
set -e
apt-get update
apt-get install -y \
ca-certificates \
curl \
apt-transport-https \
lsb-release \
@donchev7
donchev7 / Js.js
Created December 1, 2020 19:56
Javascript
const swap = ([first, second]) => [second, first];
console.log( swap([1, 2]) ); // [2, 1]
const rotate = ([first, ...rest]) => [...rest, first];
console.log( rotate([1, 2, 3]) ); // [2, 3, 1]
const arrToObj = ([key, value]) => ({ [key]: value });
console.log( arrToObj([ 'foo', 'bar' ]) ); // { "foo": "bar" }
const createUser = ({
@donchev7
donchev7 / bash-starter.sh
Created December 21, 2020 10:33
Bash script scaffold
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@donchev7
donchev7 / js-reducer.js
Last active January 6, 2021 12:42
Common use cases for JavaScript reduce built in function
//Summing an Array of Numeric Properties
const lineItems = [
{ description: 'Eggs (Dozen)', quantity: 1, price: 3, total: 3 },
{ description: 'Cheese', quantity: 0.5, price: 5, total: 2.5 },
{ description: 'Butter', quantity: 2, price: 6, total: 12 }
]
const sumReducer = (sum, val) => sum + val
lineItems.map(li => li.total).reduce(sumReducer, 0)
@donchev7
donchev7 / dates.js
Last active January 6, 2021 13:00
Working with dates in JavaScript without dependencies
//String + Date Format
const datePattern = /^(\d{2})-(\d{2})-(\d{4})$/
const [, month, day, year] = datePattern.exec('12-25-1995')
new Date(`${month}, ${day} ${year}`)
// => "1995-12-24T13:00:00.000Z"
//String + Time Format