Skip to content

Instantly share code, notes, and snippets.

View dhruvasagar's full-sized avatar

Dhruva Sagar dhruvasagar

View GitHub Profile
#!/bin/bash
# GistID: 87c59acf3b53cf1911bc6e3a8055afbf
_call_func () {
declare -f -F "$1" && $1
}
typeset -A _dirsh_cache
_dirsh_hook () {
@a7madgamal
a7madgamal / dark.md
Last active July 14, 2023 04:00
Dark mode for Slack on MacOS
@asukakenji
asukakenji / 0-go-os-arch.md
Last active November 6, 2024 03:19
Go (Golang) GOOS and GOARCH

Go (Golang) GOOS and GOARCH

All of the following information is based on go version go1.17.1 darwin/amd64.

GOOS Values

GOOS Out of the Box
aix
android
@jorinvo
jorinvo / challenge.md
Last active April 21, 2023 17:14
This is a little challenge to find out which tools programmers use to get their everyday tasks done quickly.

You got your hands on some data that was leaked from a social network and you want to help the poor people.

Luckily you know a government service to automatically block a list of credit cards.

The service is a little old school though and you have to upload a CSV file in the exact format. The upload fails if the CSV file contains invalid data.

The CSV files should have two columns, Name and Credit Card. Also, it must be named after the following pattern:

YYYYMMDD.csv.

@dhruvasagar
dhruvasagar / gist:2cde7e4f5490fdda3efa
Last active August 29, 2015 14:03
SSH Public Key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCZH/9G6dnwQRu0Rtij382bIIjIE7Eb/1Ja1w9kBN3DwPXMZsfY22XYNJHCspcoyhHpwUR1ZxMoCs4cmh3PVv1Gq9PHX9ogsO0ufeoZdHeoFv53L2yU9nRVtPAqZfkQxrlXQWmDFFHWpld7i4tNZp9j0KW1SS91a9wvttnSo4FwWi8BrUprN9iECaYPgPwwiRybQ37D4grTjbr3SdMev+vCYKVpTQftC7HzRvTJXTO/vHm+16sEOjM+LwqnGipGuBfQjHJnHVwlAT+aF8JxCseitI9TD+52e+5ZJ4oPzStRiccVdFJEkmGglo5n2ZVoN9Di6RL6PJ/SUzAKF8lbpxlf dhruvasagar@dhruvasagar
@tlrobinson
tlrobinson / post-receive
Last active December 7, 2022 08:15
Super simple git post-receive hook for Node.js + nvm + npm + node-foreman + init (Ubuntu) deployment
#!/usr/bin/env bash
set -u
set -e
export GIT_WORK_TREE="/var/www/example.com"
export NODE_VERSION="0.10"
echo "--> Checking out..."
git checkout -f
@kshenoy
kshenoy / FoldAllBut.vim
Last active December 15, 2015 18:09
Function to open folds that have less than the specified number of lines
function! FoldAllBut( foldminlines )
" Description: Function to open folds that have less than the specified number of lines
" We assume that the folds are initially closed
" If a fold exists and is closed and has lesser number of lines than specified, open it and all nested folds
" Note: This does not work on nested folds
folddoclosed
\ if (( foldclosed(".") >= 0 ) && ( foldclosedend(".") - foldclosed(".") + 1 < a:foldminlines ))
\ exe 'normal! zO'
\ endif
endfunction
@ryanb
ryanb / abilities.rb
Created September 15, 2012 19:23
How you can break up large Ability class in CanCan
module Abilities
def self.ability_for(user)
if user.admin?
AdminAbility.new(user)
else user
MemberAbility.new(user)
else
GuestAbility.new
end
end
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a