Skip to content

Instantly share code, notes, and snippets.

@trmaphi
trmaphi / getProps.js
Created August 19, 2019 07:34
Safely get a nested property of an object in Javascript
const get = (p, o) => p.reduce((xs, x) => (xs && xs[x]) ? xs[x] : null, o);
@trmaphi
trmaphi / changeJDK.bash
Last active April 5, 2024 04:06
[Change system wide java version on Mac OS] Inspire by a stackoverflow answer https://stackoverflow.com/a/44169445/6730571 #bash #mac
#!/usr/bin/env bash
JDKS_DIR="/Library/Java/JavaVirtualMachines"
JDKS=( $(ls ${JDKS_DIR}) )
JDKS_STATES=()
# Map state of JDK
for (( i = 0; i < ${#JDKS[@]}; i++ )); do
if [[ -f "${JDKS_DIR}/${JDKS[$i]}/Contents/Info.plist" ]]; then
JDKS_STATES[${i}]=enable
@trmaphi
trmaphi / printArray.c
Created March 31, 2019 10:50
[Print array] Print character array in c #c #print
void printArray(char arr[], int size){
for (int i = 0; i < size; ++i)
{
printf("%c", arr[i]);
}
printf("\n");
}
@trmaphi
trmaphi / Microsoft.PowerShell_profile.ps1
Last active March 31, 2019 10:51
[Powershell Profile setup] My personal Powershell profile setup location #powershell
# Import module on shell
Import-Module posh-git
# Chocolatey tab completion
Import-Module “$env:ChocolateyInstall\helpers\chocolateyProfile.psm1”
# Function for load Developer Command Prompt for VS 2017 executables, Community Edition
function Load-VSDev {
Push-Location "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools"
cmd /c "VsDevCmd.bat&set" |
@trmaphi
trmaphi / 50-marblemouse.conf
Last active March 31, 2019 10:51
[Logitech USB Trackball configuration for scrolling] Tested on Ubuntu 18.04 LTS. Place this file under /usr/share/X11/xorg.conf.d/ #ubuntu #trackball
Section "InputClass"
Identifier "Marble Mouse"
MatchProduct "Logitech USB Trackball"
Driver "libinput"
Option "ScrollMethod" "button"
Option "ScrollButton" "8"
Option "MiddleEmulation" "on"
EndSection
@trmaphi
trmaphi / installKitematic.sh
Last active April 17, 2020 17:47
Kitematic install script for Ubuntu
#!/usr/bin/env bash
set -v -e
BASEDIR=$(dirname "$0")
echo "$BASEDIR"
# Get link for latest release .deb package
URL=$(curl -s "https://api.github.com/repos/docker/kitematic/releases/latest" | grep browser_download_url | grep Ubuntu | cut -d '"' -f 4)
ZIPFILE=$(basename "${URL}")
curl --fail -LO "$URL" --output "${BASEDIR}/${ZIPFILE}"