Skip to content

Instantly share code, notes, and snippets.

View hadisfr's full-sized avatar

H@di hadisfr

View GitHub Profile
@hadisfr
hadisfr / python_on_ubuntu.md
Last active January 14, 2024 17:03
a short guide to install python3 and pip3 on Ubuntu Server

Python on Ubuntu

Tricks

Ubuntu

Disable X-Server on Ubuntu Desktop

  • edit /etc/default/grub and change
@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
}
#!/bin/bash
# Run in go using -
# <exec command="bash">
# <arg>-c</arg>
# <arg>curl -s https://gist.githubusercontent.com/hadisfr/57750e9ae05a57989f17742536f82ee3/raw/ansi-color-test.sh | bash</arg>
# </exec>
bash <( curl -s https://raw.githubusercontent.com/fidian/ansi/master/ansi) --color-table
#!/usr/bin/env python3
import sys
import urllib.request
from urllib.error import HTTPError
BASE_URL = 'http://dx.doi.org/'
try:
doi = sys.argv[1]
@hadisfr
hadisfr / firefox_bookmarks_to_csv.py
Created September 10, 2018 13:28
get a csv spreadsheet from Firefox json-exported bookmarks
#!/usr/bin/env python3
import json
import csv
def process(bookmark):
global res
if 'children' in bookmark.keys():
for child in bookmark['children']:
cd $FOAM_RUN
cp -ar $FOAM_TUTORIALS/incompressible/icoFoam/cavity/cavity .
cd cavity
blockMesh
icoFoam
touch cavity.foam
cd $FOAM_RUN
cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily .
cd pitzDaily
@hadisfr
hadisfr / spim.md
Created July 22, 2019 14:25
mips simulator short cheatshit

SPIM

mips simulator

  • non-interactive:
    spim -f <file>
  • interactive
    load "<file>"
    

print_sym (only sees .globl labels)