Skip to content

Instantly share code, notes, and snippets.

@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}"
@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 / 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 / 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 / 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 / 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);
var AWS = require('aws-sdk');
var region = ''; // e.g. us-west-1
var domain = ''; // e.g. search-domain.region.es.amazonaws.com
var index = 'node-test';
var type = '_doc';
var id = '1';
var json = {
"title": "Moneyball",
"director": "Bennett Miller",
@trmaphi
trmaphi / noti.sh
Created March 12, 2020 12:15
Notify slack incoming webhooks about current deployment
#!/usr/bin/env bash
TARGET=$(git describe --dirty --broken --all --long);
PROJECT=$(git config remote.origin.url |sed 's#.*\/\(.*\)\.git#\1#');
git pull && \
curl -i \
-H "Content-Type:application/json" \
-X POST \
-d "{\"text\": \"deployed \`${PROJECT}\` \`$TARGET\` to \`$1\` \"}" \
@trmaphi
trmaphi / x-ray-graphql.ts
Last active January 4, 2021 04:28
Tracing GraphQL resolvers with X-Ray
import traceResolvers from '@lifeomic/graphql-resolvers-xray-tracing';
// Apply tracing middleware if running Lambda environment
if (process.env.AWS_LAMBDA_FUNCTION_NAME) {
traceResolvers(schema);
}
const apolloServer = new ApolloServer({
schema,
context: contextFn,
@trmaphi
trmaphi / tracing.ts
Last active January 7, 2021 03:53
Setup X-ray on Lambda
/// Setup tracing in a separate file
import * as AWSXRay from 'aws-xray-sdk-core';
// Configure the context missing strategy to do nothing
// https://docs.aws.amazon.com/lambda/latest/dg/nodejs-tracing.html
AWSXRay.setContextMissingStrategy(() => { });
// https://github.com/aws/aws-xray-sdk-node/issues/143
AWSXRay.captureAWS(require('aws-sdk'));