Skip to content

Instantly share code, notes, and snippets.

@karanjitsingh
karanjitsingh / iTermNewWindow (Quick Action)
Last active June 1, 2025 18:42
iTerm HotKey Automator
-- Automator Quick Action
-- -----------------------------------------------
-- Workflow receives no input
-- Set keyboard shortcut for Services/General/...
on run {input, parameters}
tell application "iTerm"
if it is running then
if (count of windows) is 0 then
create window with default profile
end if
@karanjitsingh
karanjitsingh / init.lua
Created May 3, 2025 00:26
neovim-config
if vim.g.vscode then
-- VSCode extension
else
-- ordinary Neovim
end
-- Use system clipboard
vim.opt.clipboard = "unnamedplus"
-- Enable case-insensitive search
@karanjitsingh
karanjitsingh / fn_toggle.applescript
Created December 27, 2021 01:33
AppleScript to toggle fn key
tell application "System Preferences"
set current pane to pane "com.apple.preference.keyboard"
end tell
tell application "System Events"
if UI elements enabled then
tell application process "System Preferences"
repeat until exists tab group 1 of window "Keyboard"
delay 0.5
end repeat
<html>
<style>
body{background:#111;margin:0;padding:0;font-family:'Segoe UI',Tahoma,Geneva,Verdana,sans-serif;font-weight:300}.gif{position:absolute;left:0;top:0;height:100%;width:100%;background-size:cover;background-repeat:no-repeat;background-position:center;z-index:-1}.full{position:absolute;left:0;top:0;height:100%;width:100%}.container{display:flex;flex-direction:column;justify-content:center}.refresh{color:#fff;display:flex;line-height:144px;justify-content:center;font-size:60px}.refresh a{background-image:url(https://images-na.ssl-images-amazon.com/images/I/41JYhXXa+rL._SX328_BO1,204,203,200_.jpg);display:inline-block;width:100px;height:144px;background-size:cover;margin-left:30px}div{text-align:center}.text{font-size:30px;width:700px;padding:10px;background:none;border:#fff 1px solid;border-radius:1000px;outline:none;text-align:center;margin-top:120px;color:#fff;font-weight:100}.text::placeholder{color:rgba(255,255,255,0.4)}.sent{color:#fff;margin-top:18px;font-size:20px;opacity:0}@keyframes hide{fr
@karanjitsingh
karanjitsingh / binance-scraper.py
Last active July 11, 2021 17:37
Binance price action data scraper
from datetime import datetime, timedelta
import time
import requests
import sys
import os
second = 1000
minute = second * 60
hour = minute * 60
day = hour * 24
@karanjitsingh
karanjitsingh / nuget_dependency_tree.cs
Created July 8, 2019 10:45
Nuget package dependency tree.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using NuGet;
namespace ConsoleApplication1
{
class Program
{
@karanjitsingh
karanjitsingh / SanitizeLogs.ps1
Created April 16, 2018 11:04
Custom log sanitizer
param(
[string] $logfile
)
$nonProtocolRegex = "^(?!.*PROTOCOL).*$"
$protocolRegex = "^.*(send|receive):(.*)"
function Format-Json([Parameter(Mandatory, ValueFromPipeline)][String] $json) {
$indent = 0;
($json -Split '\r\n' |
@karanjitsingh
karanjitsingh / repro.py
Last active March 19, 2018 04:50
Script for reproducing errors in flaky tests in Microsoft/vstest. i.e. Tests that fail randomly with low probability.
# Usage
# Python repro.py <VSTEST folder> <ProjectPattern> <TestFilter>
#
# Uncomment the two lines for test output
# Log paths are hardcoded at D:\logs
#
# Logs will be cleared after every successful run
# (What's the point of having the logs when it didn't repro?)
import subprocess
@karanjitsingh
karanjitsingh / codecount.sh
Last active February 8, 2018 20:32
Count your code using shell
# Usage: ./codecount.sh css js html
lines=0
for var in "$@"
do
count=0
count=$( find ./ -regex ".*\.$var" | ( while read line; do
count=`wc -l $line`
@karanjitsingh
karanjitsingh / portable_packages.py
Last active June 1, 2017 10:28
.NET Core portable assemblies package.config generator. Convert* your .NET Standard project to .NET Core.
# Copy your .NET standard project files to an empty .NET core project and build it
# Save the error log to a file (eg. builderrors.log)
#
# Usage:
# python portable_packages.py builderrors.log packages.config
#
# NOTE: NOT ALL ASSEMBLIES IN .NET STANDARD ARE SUPPORTED BY .NET CORE
import re
import sys