Skip to content

Instantly share code, notes, and snippets.

View debodirno's full-sized avatar

Debodirno Chandra debodirno

View GitHub Profile
@debodirno
debodirno / python@2.rb
Last active October 31, 2020 08:23
Python 2 has reached its end of life. So "brew install python@2" does not work. Download this file to your current directory, and run brew install python@2.rb
class PythonAT2 < Formula
desc "Interpreted, interactive, object-oriented programming language"
homepage "https://www.python.org/"
url "https://www.python.org/ftp/python/2.7.17/Python-2.7.17.tar.xz"
sha256 "4d43f033cdbd0aa7b7023c81b0e986fd11e653b5248dac9144d508f11812ba41"
revision 1
head "https://github.com/python/cpython.git", :branch => "2.7"
bottle do
sha256 "accfaa922708f00afb69ab230199f96e6ecdddd248a1eca586ce1e5e5cfd732b" => :catalina
@debodirno
debodirno / README.md
Last active June 25, 2020 20:48
Bash Set Builtin Examples

Bash Set Builtin

Use strict modes unless you have a good reason not to:

  • Use set -e to abort on errors (nonzero exit code)
  • Use set -o pipefail too, to abort on errors within pipes (though read up on it more if you do, as this topic is a bit subtle).
  • Use set -u to detect unset variable usages.
  • Use set -x (or the variant set -v, which logs raw input, including unexpanded variables and comments) for debugging output.

Reference

  1. https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
@debodirno
debodirno / gitcheats.txt
Created May 30, 2020 19:31 — forked from chrismccoy/gitcheats.txt
git cheats
# shortform git commands
alias g='git'
# pretty tab'd git log
git log --graph --pretty="tformat:%h*(%ar)*<%an>*%d %s" $* | sed -Ee 's/(^[^<]*) ago\)/\1)/' | sed -Ee 's/(^[^<]*), [[:digit:]]+ .*months?\)/\1)/' | column -s '*' -t | cat
# change author of all git repos
git filter-branch -f --env-filter "GIT_AUTHOR_NAME='yourname'; GIT_AUTHOR_EMAIL='youremail@example.com'; GIT_COMMITTER_NAME='yourname'; GIT_COMMITTER_EMAIL='youremail@example.com';" HEAD;
# stage only deleted files
@debodirno
debodirno / simple-git.zsh-theme
Last active July 26, 2019 08:57
A simple git theme with current directory, current branch
PROMPT='%(!..%{$fg[red]%}$USER %{$fg[yellow]%})%2~%{$fg[cyan]%}$(git_prompt_info)%{$reset_color%} %{$fg_bold[blue]%}%(!.#.$) '
ZSH_THEME_GIT_PROMPT_PREFIX=" ("
ZSH_THEME_GIT_PROMPT_SUFFIX=")"
@debodirno
debodirno / java_collections_complexities.md
Created April 17, 2019 10:30
Big O Complexities of common functions of different Java collections

Below are the Big O performance of common functions of different Java Collections.

List Add Remove Get Contains Next Data Structure
ArrayList O(1) O(n) O(1) O(n) O(1) Array
LinkedList O(1) O(1) O(n) O(n) O(1) Linked List
CopyOnWriteArrayList O(n) O(n) O(1) O(n) O(1) Array
@debodirno
debodirno / Git aliases
Created February 10, 2019 17:30
Frequently used git aliases
alias g='git'
alias ga='git add'
alias gapa='git add --patch'
alias gb='git branch'
alias gbd='git branch -d'
alias gbD='git branch -D'
alias gc='git commit -v'
@debodirno
debodirno / gist:05ef564252c9f5c4c0c923cdcbe2ec36
Created November 8, 2018 20:23 — forked from digitaljhelms/gist:4287848
Git/GitHub branching standards & conventions

Branching

Quick Legend

Description, Instructions, Notes
Instance Branch
@debodirno
debodirno / Securing from SQL Injection
Last active April 17, 2018 20:05
This script will show the ways we can clean up arrays such that SQL Injection is prevented. This can be used as a common include file in handlers. Inspired by : https://www.danbarbulescu.com/php-sql-injection-postget-protection/
function secure_array(&$array) {
// this function secures the content of an array against SQL injection and HTML code injection attacks
// it works for arrays of any number of dimensions, recursively for each dimension
if (isset($array)) {
foreach ($array as $key => $value) {
if (is_array($array[$key])) { // if element is array, then go to next dimension
secure_array($array[$key]);
} elseif (is_string($array[$key])) { // if element is a string variable, clean it up
$array[$key] = $mysqli -> real_escape_string($array[$key]); // replace this with mysql / PDO real escape string function depending on which database connector you are using