Skip to content

Instantly share code, notes, and snippets.

Avatar

Ben Cawrse bcawrse

View GitHub Profile
@bcawrse
bcawrse / install-choco-script.bat
Last active Dec 30, 2019 — forked from zaccb/install-choco-script.bat
Chocolatey install script
View install-choco-script.bat
:: Install choco .exe and add choco to PATH
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
:: Install all the packages
:::: Browsers
choco install googlechrome -fy
choco install firefox -fy
:::: Text editors / IDEs
::choco install atom -fy
@bcawrse
bcawrse / .aliases
Last active May 20, 2021
Setup Zsh on fresh debian-based install
View .aliases
# General CLI utility.
alias la='ls -lAhF'
alias lar='ls -AhF'
alias ll='ls -lhF'
alias l='ls -hF'
alias cl='clear; lar'
alias c='clear;'
alias xg='xargs egrep -sin --color'
alias hostip="ip route get 0.0.0.0/0 | grep -Eo 'via \S+' | awk '{ print \$2 }'"
@bcawrse
bcawrse / .vimrc
Last active Jul 22, 2021
General .vimrc file
View .vimrc
set tabstop=2
set shiftwidth=2
set textwidth=120
set expandtab
set number
set hlsearch
set pastetoggle=<F2>
:color delek
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! w !sudo tee > /dev/null %
@bcawrse
bcawrse / tmux.conf
Last active Aug 30, 2021
tmux configuration file
View tmux.conf
## Use vi keys for scrolling etc.
set-window-option -g mode-keys vi
## Extend how long pane #s are displayed
## Useful for `ctrl-b q` # to switch between panes
set -g display-panes-time 4000
## Auto renumbers windows when they are deleted
set -g renumber-windows on
## alternatively, this command will reorder windows
@bcawrse
bcawrse / terminalFlatTheme.sh
Created Aug 17, 2019 — forked from anmoljagetia/terminalFlatTheme.sh
This gist shows how to setup terminal colors in the new gnome-terminal (v 3.14) and above. This was generated using a site called http://terminal.sexy
View terminalFlatTheme.sh
#!/usr/bin/env bash
# Base16 - Gnome Terminal color scheme install script
[[ -z "$PROFILE_NAME" ]] && PROFILE_NAME="terminal.flat.theme"
[[ -z "$PROFILE_SLUG" ]] && PROFILE_SLUG="terminal-flat-theme"
[[ -z "$DCONF" ]] && DCONF=dconf
[[ -z "$UUIDGEN" ]] && UUIDGEN=uuidgen
dset() {
local key="$1"; shift
View gitGlobalConfig.sh
# Set the editor to vim.. duh
git config --global core.editor vim
# Add aliases
git config --global alias.logthis 'log --decorate --date-order --graph --tags HEAD'
git config --global alias.logall 'log --decorate --date-order --remotes --graph --tags --branches'
git config --global alias.logalls 'log --decorate --date-order --remotes --graph --tags --branches --stat'
git config --global alias.diffc 'diff --cached'
git config --global alias.count 'count-objects -vH'
git config --global alias.package '"!f() { git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT $1..HEAD; }; f"'
@bcawrse
bcawrse / flatten.js
Last active Aug 21, 2019
Flatten example written in Node with jest tests
View flatten.js
/**
* Flattens provided array.
*
* If an array is provided, this function will flatten it.
* EXAMPLE: flatten([[1, 2, [3]], 4]) returns [1, 2, 3, 4].
*
* @throws Throws an exception if provided parameter is not an Array.
* @param {Array} arr Array to flatten.
* @return {array} Flattend Array.
**/
View google sheets email script
function sendEmail() {
try {
var ss = SpreadsheetApp.getActive();
var ssID = ss.getId();
var date = Utilities.formatDate(new Date(), "GMT+5", "dd/MM/yyyy")
var subject = "Subject of Email : " + date;
var message = "Message in email body"
var sheet = DriveApp.getFileById(ssID);
var sentbyName = "Name shown for email sentby";
var email = Session.getEffectiveUser();
@bcawrse
bcawrse / Package-Restore.md
Last active Sep 6, 2019
Simple details for Update-Package -Reinstall within Visual Studio for NuGet on .Net 4
View Package-Restore.md

Using Update-Package -Reinstall for NuGet

Tired of having to look this up everytime I need it, so saving it in a gist. Original SO answer

Note you can force package restore to execute by running the following commands in the nuget package manager console

Update-Package -Reinstall

Forces re-installation of everything in the solution.

View Magic Sql Server Index Fixer
/****** Object: StoredProcedure [dbo].[usp_showIndexFragmentation] Script Date: 12/10/2019 3:15:50 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>