Skip to content

Instantly share code, notes, and snippets.

View alireza-ahmadi's full-sized avatar

Alireza Ahmadi alireza-ahmadi

View GitHub Profile
@alireza-ahmadi
alireza-ahmadi / commands.sh
Last active August 3, 2021 03:58
A quick benchmark of two slightly different solutions for checking whether an interface has any empty fields or not
# ----------------- 1 ----------------
# Make sure that both methods work as expected
go test
# Output ->
# PASS
# ok github.com/alireza-ahmadi/isempty 0.677s
# ----------------- 2 ----------------
# Run benchmark to understand the performance difference
@alireza-ahmadi
alireza-ahmadi / redirect.js
Created January 10, 2014 20:24
A simple Node.js solution for 301 redirect
var http = require('http');
var server = http.createServer(function(req, res){
res.writeHead(301, {'Location' : 'http://www.example.com'});
res.end();
});
server.listen(process.env.PORT || 3000);
# Aliases
alias o="open ."
alias pi="ping blogfa.com"
alias gis="git status"
alias gad="git add"
alias gil="git log"
alias s="source"
alias sp="spotify"
alias google-chrome="open -a 'Google Chrome'"
alias y="yarn"
// # Usage
//
// Save this file and replace username and password on the last line of the file with
// your Snapp username and password then run the following commands:
//
// yarn init && yarn add request
// node SnappTotalPriceCalculator.js
//
const request = require('request');
@alireza-ahmadi
alireza-ahmadi / todo.md
Last active March 22, 2018 13:43 — forked from DeckerCHAN/todo.md
Gist todo list

To Do

  • for an empty checkboxP
  • for a checked checkboxP
@alireza-ahmadi
alireza-ahmadi / BrewPackages.txt
Created November 11, 2016 14:15
List of my installed brew packages - `brew list`
ack
autoconf
automake
awscli
axel
cairo
cassandra
ccat
cctools
cloc
@alireza-ahmadi
alireza-ahmadi / bullet.zsh
Last active November 11, 2016 13:58
My ZSH setup
# Bullet Theme v0.1.0
#
# @author Alireza Ahmadi <info@alireza.es>
PROMPT=' %{$fg_bold[black]%}●%{$fg_bold[green]%}%p %{$fg_bold[blue]%}%c $(git_prompt_info)% %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_CLEAN="> %{$fg_bold[cyan]%}✛ "
ZSH_THEME_GIT_PROMPT_DIRTY="> %{$fg_bold[red]%}✕ "
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[magenta]%}<"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"

My defaults write options

[Decrease dock's auto-hide delay]
defaults write com.apple.dock autohide-delay -float 0 && defaults write com.apple.dock autohide-time-modifier -float 0 && killall Dock
defaults delete com.apple.dock autohide-delay && defaults delete com.apple.dock autohide-time-modifier && killall Dock

[Speed up mission control animations]
defaults write com.apple.dock expose-animation-duration -float 0.12 && killall Dock
defaults delete com.apple.dock expose-animation-duration && killall Dock
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Insert `ALL_PROXY=socks5://server:port` before the command by pressing
# ESC and p. Heavily inspired by oh-my-zsh's sudo plugin.
#
# ------------------------------------------------------------------------------
# Authors
# -------
/**
* Useful function for Melli code validation
* @author Alireza Ahmadi info@alireza.es
* @param code {String} Melli code
* @return {Boolean} Melli code credential
*/
var MelliCode = function(code){
if(code.length != 10) {
return false;
}