Skip to content

Instantly share code, notes, and snippets.

View hadisfr's full-sized avatar

H@di hadisfr

View GitHub Profile
@hadisfr
hadisfr / bash_profile
Last active October 5, 2017 21:05
part of ~/.bash_profile
# ~/.bash_profile
alias ls='ls --color=auto'
alias grep="grep --color=auto"
alias diffstat="diffstat -C"
alias hiddneFilesShow='defaults write com.apple.finder AppleShowAllFiles YES && rm ~/.DS_Store; killall Finder /System/Library/CoreServices/Finder.app'
alias hiddneFilesHide='defaults write com.apple.finder AppleShowAllFiles NO && rm ~/.DS_Store; killall Finder /System/Library/CoreServices/Finder.app'
function aria2webui(){
@hadisfr
hadisfr / DE2_TOP.v
Last active October 19, 2017 13:58
some ALTERA DE2 FPGA files for Quartus II
// ============================================================================
// Copyright (c) 2012 by Terasic Technologies Inc.
// ============================================================================
// Permission:
// Terasic grants permission to use and modify this code for use
// in synthesis for all Terasic Development Boards and Altera Development
// Kits made by Terasic. Other use of this code, including the selling
// ,duplication, or modification of any portion is strictly prohibited.
@hadisfr
hadisfr / Virtual Box Host Only Static IP.md
Last active February 18, 2018 23:29 — forked from pjdietz/Virtual Box Host Only Static IP.md
VirtualBox Host-Only Adapter with Static IP

VirtualBox Host-Only Static IP

My typical setup for a development box in VirtualBox uses two NICs. The first uses NAT to allow the box to communicate with the outside world through my host computer’s network connection. (NAT is the default, so shouldn't require any setup.) The second is a "host-only" connection that allows my host and guest to interact.

To create a host-only connection in VirtualBox, start by opening the preferences in VirtualBox. Go to the "Network" tab, and addd a Host-only Network. Modify the host-only network, and disable DHCP. Make a note of the IP address. (Feel free to set the IP address as well, if you like.)

Next, assign this host-only adapter to the virtual machine. Select the VM and press "Settings". Go to the "Network" tab, and select "Adpater 2". Enable the adapter, set it to a "Host-only Adapter", and select the adpater you created above.

NAT Troubleshooting

@hadisfr
hadisfr / subtitle_corrcetor.sh
Last active June 5, 2018 00:17
convert subtitles' encoding from Arabic(Windows) to UTF-8
#!/usr/bin/env bash
for f in `find . -name "*.srt"`; do
iconv -f ms-arab -t utf8 $f > ${f%".srt"}.u.srt
echo -e ${f%".srt"}.u.srt
done
@hadisfr
hadisfr / agnoster_bash.sh
Last active July 20, 2018 05:34
a bash theme like agnoster zsh theme - migrated to https://github.com/hadisfr/agnoster_bash
#!/usr/bin/bash
# Agnoster BASH Theme
#
# Author: H@di(info@hadisafari.ir)
#
# Usage: 1. set a powerline-compatible font for terminal
# 2. append this file to your ~/.bash_profile
#
# • powerline-compatible fonts: https://github.com/powerline/fonts/tree/master/SourceCodePro
@hadisfr
hadisfr / compile_kernel.bash
Last active July 20, 2018 05:48
a bash script to compile and run linux kernel using qemu and gdb - migrated to https://github.com/hadisfr/compile_kernel
#!/usr/bin/env bash
# a script to compile and run linux kernel using qemu and gdb
#
# author: hadi_sfr(info@hadisafari.ir)
#
# Usage:
# Download .tar.gz kernel file from https://www.kernel.org/pub/linux/kernel/
# Put .tar.gz file besdie this script
# Run the script
@hadisfr
hadisfr / Python2.7-Pip-Virtualenv.md
Last active August 6, 2018 06:27 — forked from hrushikesh198/Python2.7-Pip-Virtualenv.md
Python2.7, Pip, Virtualenv Installation on Mac or Linux machines for the current user without sudo access

Installing Python2.7

If you download a different version it should work similarly.

cd ~
wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz
tar -xzvf Python-2.7.13.tgz
cd Python-2.7.13
./configure 
make altinstall prefix=~/.local/
@hadisfr
hadisfr / lint-c++.sh
Created August 13, 2018 16:48
lint c++ codes of a project using clang-format
find . -name *.cpp -exec bash -c 'cmp <(clang-format --style=LLVM $0) $0' {} \;
@hadisfr
hadisfr / vpn.sh
Last active August 13, 2018 17:01
run cisco anyconnect vpn client from macOS terminal
#!/bin/sh
/opt/cisco/anyconnect/bin/vpn -s << EOF
connect hosthere:porthere
usernamehere
passwordhere
exit
EOF
@hadisfr
hadisfr / svg2tex.sh
Created August 21, 2018 15:11
convert svg files to LaTeX-compatible pdf
function svg2tex {
_addr=$(readlink -f $1)
inkscape -D -z --file=$_addr --export-pdf=${_addr/.svg/.pdf} --export-latex
}