Skip to content

Instantly share code, notes, and snippets.

View lvnilesh's full-sized avatar
💭
🏆 Vibranium Status Level

LV Nilesh lvnilesh

💭
🏆 Vibranium Status Level
View GitHub Profile
@lvnilesh
lvnilesh / toggle-applescript-dnd. scpt
Created September 14, 2021 00:00 — forked from Sanabria/toggle-applescript-dnd. scpt
Applescript: Toggle Do Not Disturb mode
(* Note 1: The 1 after menu bar may need to be changed to 2 when using multiple monitors *)
(* Note 2: For 10.11 and newer “NotificationCenter” is now spelled “Notification Center”*)
tell application "System Events"
tell application process "SystemUIServer"
try
if exists menu bar item "Notification Center, Do Not Disturb enabled" of menu bar 1 of application process "SystemUIServer" of application "System Events" then
(* It is disabled *)
display dialog "Notifications will be turned on" buttons {"Got it"} default button 1
key down option
@lvnilesh
lvnilesh / Ensemble.plist
Created September 10, 2021 17:35 — forked from zhuowei/Ensemble.plist
Put this file as /Library/Preferences/FeatureFlags/Domain/Ensemble.plist and reboot to (hopefully) turn on Universal Control on macOS 12
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- not sure which one it is, so set both -->
<key>Ensemble</key>
<dict>
<key>Enabled</key>
<true/>
</dict>
@lvnilesh
lvnilesh / code.sh
Created August 18, 2021 15:44 — forked from tallguyjenks/code.sh
ZettelKasten Sync Code
# To permanently cache the credentials
git config --global credential.helper store
# To ignore files that could cause issues across different workspaces
touch .gitignore
echo ".obsidian/cache
.trash/
.DS_Store" > .gitignore
@lvnilesh
lvnilesh / jenkins_build_skip.md
Created August 5, 2021 20:14 — forked from eddiecorrigall/jenkins_build_skip.md
Jenkins: Build only when necessary

Build Only When Necessary

In testing environments, it is not always useful repeating tasks which can cost developers valuable time. Within a project its safe to assume that not all files are changed, so why rebuild?

This tutorial outlines a method to reduce unnecessarly build steps. Use your best judgement of course. It might be useful to add in a build on occassion to ensure third party dependencies are available and will not disrupt a production deployment.

Jenkins Setup

The git plugin in Jenkins provides several useful environment variables which can be used to avoid build tasks. Make sure you setup the git plugin before going any further.

@lvnilesh
lvnilesh / Jenkinsfile
Created August 4, 2021 05:11 — forked from ftclausen/Jenkinsfile
Jenkins pipeline - An approach to get all commits since the last successful build.
// -*- mode: groovy -*-
// vim: set filetype=groovy :
node( 'some_node' ) {
stage( "Phase 1" ) {
sshagent( credentials: [ 'some_creds' ] ) {
checkout scm
def lastSuccessfulCommit = getLastSuccessfulCommit()
def currentCommit = commitHashForBuild( currentBuild.rawBuild )
if (lastSuccessfulCommit) {
@lvnilesh
lvnilesh / user-data.sh
Created July 25, 2021 21:57 — forked from kevupton/user-data.sh
User Data for initializing an EC2 using Ubuntu with Docker GPU
#!/bin/bash
sudo apt-get remove docker docker-engine docker.io
sudo apt-get update -qq
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
@lvnilesh
lvnilesh / socat_socks_proxy.sh
Created July 24, 2021 21:54 — forked from lene/socat_socks_proxy.sh
Using tor as SOCKS proxy with SOCAT
socat TCP-LISTEN:<localport> SOCKS4A:localhost:<host>:<remoteport>,socksport=9050
# for example, to ssh into secret.shell.server.org via tor, do:
$ socat TCP-LISTEN:22222 SOCKS4A:localhost:secret.shell.server.org:22,socksport=9050 &
$ ssh localhost -p 22222
@lvnilesh
lvnilesh / tor.sh
Created July 24, 2021 04:02 — forked from jakejarvis/tor.sh
system-wide Tor proxy on macOS
#!/usr/bin/env bash
#
# ######################################################################
# Start Tor and switch the system-wide proxy settings in macOS
# ----------------------------------------------------------------------
# Usage:
# `./tor.sh` in Terminal, kill with ctrl + c
# ----------------------------------------------------------------------
# Source:
# https://kremalicious.com/simple-tor-setup-on-mac-os-x/
<Link
href={
encodeURI(utils.isAndroid() ?
`sms:+14252233474?body=Hey Nilesh, I have a question.`
:
`sms:+14252233474&body=Hey Nilesh, I have a question.`
)}
className={`${classes.fontWhite} footer-link-hover`}
underline="none"
>
@lvnilesh
lvnilesh / purgehostkey.zsh
Created June 17, 2021 22:14 — forked from nathanalderson/purgehostkey.zsh
zsh function for deleting the bad host key from the previous ssh command
# delete the bad host key from the previous ssh command
purgehostkey() {
cmd=$history[$((HISTCMD-1))]
lineno=$(eval $cmd 2>&1 | grep -oP 'known_hosts:\K\d+')
known_hosts=~/.ssh/known_hosts
host=$(sed -n "${lineno}p" $known_hosts | cut --delimiter=' ' --fields=1)
sed -i -e "${lineno}d" $known_hosts
echo "Deleted $host from known_hosts:$lineno 🖥️🔑💥"
eval $cmd -o StrictHostKeyChecking=accept-new
}