Skip to content

Instantly share code, notes, and snippets.

View huskercane's full-sized avatar

Rohit Singh huskercane

  • Citrix
  • United States
  • 14:39 (UTC -05:00)
  • X @huskercane
View GitHub Profile
import logging
class CustomFormatter(logging.Formatter):
grey = "\x1b[38;20m"
yellow = "\x1b[33;20m"
red = "\x1b[31;20m"
bold_red = "\x1b[31;1m"
green = "\x1b[38;2;0;255;0m"
sky_blue = "\x1b[38;2;135;206;235m"
param (
[string]$COMMIT_MSG_FILE,
[string]$COMMIT_SOURCE,
[string]$SHA1
)
# Get the current branch name
$BRANCH_NAME = (git rev-parse --abbrev-ref HEAD 2>$null)
# Ensure BRANCH_NAME is not empty and is not in a detached HEAD state (i.e. rebase).
@huskercane
huskercane / prepate-commit-msg.sh
Created October 24, 2023 19:36
Add jira id to commit message
#!/bin/sh
#
# Inspects branch name and checks if it contains a Jira ticket number (i.e. ABC-123).
# If yes, commit message will be automatically prepended with [ABC-123].
#
# Useful for looking through git history and relating a commit or group of commits
# back to a user story.
#
COMMIT_MSG_FILE=$1
local cmd = vim.cmd
cmd 'packadd paq-nvim'
local paq = require('paq-nvim').paq
paq{'savq/paq-nvim', opt=true}
paq {'nvim-treesitter/nvim-treesitter', run=':TSUpdate'}
paq {'nvim-treesitter/playground'}
paq {'neovim/nvim-lspconfig'}
// based on https://boyter.org/posts/file-read-challange/?utm_medium=email&utm_source=topic+optin&utm_campaign=awareness&utm_content=20190511+prog+nl&mkt_tok=eyJpIjoiWTJNMU16UTJZekU0T1dZeCIsInQiOiJqWnNJYkhxYWJBbklUcEFDTmQxdVh4OHVhREliRE5LcFlQa0hCRjRnSlg2SzZ2MFF4VVhDTGZlNEJDUlwvOXZkeXBkOTFHUFNYOEh4N2pvVWExTWppTWhQRm50ZzRaNkdOb2ErZjI2THRKZXNhN1BHcGcyams1S0pFZitLcjZwUEwifQ%3D%3D
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.time.Instant;
import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
@huskercane
huskercane / safeadd.java
Created June 5, 2018 14:02
safe addition in java - not to overflow
public class X {
public static final int safeAdd(int left, int right){
if (right > 0? left > Integer.MAX_VALUE - right: left < Integer.MIN_VALUE - right) {
// throw new ArithmeticException("Integer overflow");
}
return (left + right);
}
}
set lines=100
set columns=133
" Enable debugging
" let g:ycm_keep_logfiles = 1
" let g:ycm_log_level = 'debug'
let g:tags_path = "/home/rohits/.ctags.d,/usr/lib/python3/dist-packages/Tags"
set tags=./tags,../tags,../inc/tags
@huskercane
huskercane / .vimrc
Last active May 24, 2021 21:11
My vimrc file
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
# http://irisclasson.com/2013/10/16/how-do-i-query-a-sql-server-db-using-powershell-and-how-do-i-filter-format-and-output-to-a-file-stupid-question-251-255/
# http://stackoverflow.com/questions/83410/how-do-i-call-a-sql-server-stored-procedure-from-powershell
# http://everythingsharepoint.blogspot.com/2011/08/call-sql-stored-procedure-from.html
$dataSource = "$env:COMPUTERNAME\VIM_SQLEXP"
$database = “VIM_VCDB”
$connectionString = “Server=$dataSource;Database=$database;Integrated Security=True;”
# write-host $connectionString
$connection = New-Object System.Data.SqlClient.SqlConnection
$connection.ConnectionString = $connectionString
const http = require ('https')
var options = {
host: '127.0.0.1',
port: 443,
path: '/admin/resources/fix_packs',
// path: '/admin/resources/change_plans',
auth: 'admin:admin',
method: 'GET',
headers: {
'X-IBM-Workload-Deployer-API-Version': '5.0',