Skip to content

Instantly share code, notes, and snippets.

View hadisfr's full-sized avatar

H@di hadisfr

View GitHub Profile
@hadisfr
hadisfr / install_jdk.sh
Created April 1, 2020 19:09
a script for installing jdk from tar file in Ubuntu
#!/usr/bin/env bash
if [[ $# != 1 ]]; then
echo -e "usage:\t$0 <url of Linux binary from https://jdk.java.net>"
exit 1
fi
if [ $EUID != 0 ]; then
sudo "$0" "$@"
exit $?
@hadisfr
hadisfr / xsel.el
Last active June 18, 2020 10:55 — forked from ktabata/xsel.el
Emacs-nox <-> X11 clipboard transfer
; You need "xsel" program.
(defun x-paste ()
"insert text on X11's clipboard to current buffer."
(interactive)
(insert (shell-command-to-string "xsel -b")))
(defun x-copy ()
"copy text on local kill-ring to X11's clipboard."
(interactive)
version: '2'
networks:
kafka:
driver: bridge
ipam:
config:
- subnet: 10.20.0.0/16
services:
@hadisfr
hadisfr / add-p.md
Last active December 1, 2019 15:53 — forked from mattlewissf/add-p.md
Lightning Talk: Git add -p

git add -p is your friend

git add -p is basically "git add partial (or patch)"

Patch mode allows you to stage parts of a changed file, instead of the entire file. This allows you to make concise, well-crafted commits that make for an easier to read history. This feature can improve the quality of the commits. It also makes it easy to remove parts of the changes in a file that were only there for debugging purposes - prior to the commit without having to go back to the editor.

It allows you to see the changes (delta) to the code that you are trying to add, and lets you add them (or not) separately from each other using an interactive prompt. Here's how to use it:

from the command line, either use

  • git add -p
@hadisfr
hadisfr / Geeklets.md
Created October 30, 2019 11:26
GeekTool Geeklets Scripts
@hadisfr
hadisfr / spin.md
Last active December 21, 2023 12:07
How to Use SPIN Model Checker

How to Use SPIN

Run Verifier

It's possible to use spin -a src.pml to create pan.[cbhmt] files. Then, it's possible to compile the generated verifier using gcc -o pan pan.c. The compiler verifier could be run by ./pan. spin -run src.pml automates the whole process.

Rerun After Failure

@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)

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 / 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']:
#!/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]