Skip to content

Instantly share code, notes, and snippets.

Mohamed A. Bamakhrama mohamed

Block or report user

Report or block mohamed

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mohamed
mohamed / git-sparse-checkout.md
Last active Oct 24, 2019
Git sparse checkout
View git-sparse-checkout.md

Using Git Sparse Checkout

Here are the steps to create a “sparse” Git local repository.

  1. Enable Sparse Checkouts

    git config core.sparsecheckout true

View vitter.c
//Copyright Kevin Lawler, released under ISC License
double random_double() //your random double function
{
//[0,1) uniformly random double, mt19937-64.c source is fine
//keep in mind most double-based implementations drop randomness to 52-bits
return genrand64_real2();
}
//POTENTIAL_OPTIMIZATION_POINT: Christian Neukirchen points out we can replace exp(log(x)*y) by pow(x,y)
@mohamed
mohamed / compound-literals.c
Last active Aug 23, 2019
C compound literals
View compound-literals.c
/*
* Compile with:
* gcc compound-literals.c -Wall -Wextra -std=c99 -Werror
*/
#include <stdio.h>
#include <stdlib.h>
struct bin_tree {
int value;
@mohamed
mohamed / test_fcvt_invalid.c
Last active Jul 1, 2019
Test IEEE 754-2008 invalid exception under conversion operations
View test_fcvt_invalid.c
/*
* Compile with:
* gcc -mavx512f -std=c89 -Wall -Wextra -Werror test_ov.c -o test_ov -lm
*/
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
/* For fe* functions */
@mohamed
mohamed / vim.rst
Last active Jul 25, 2019
Vim cheatsheet
View vim.rst

Misc

guu                         : lowercase line
gUU                         : uppercase line
g~~                         : flip case line
gf                          : open file name under cursor (SUPER, requires :set path+=<path_to_file>)
<C-w>f                      : open file name under cursor in a new window
@mohamed
mohamed / xkcd.tex
Created Mar 5, 2019
XKCD style plots in LaTeX
View xkcd.tex
\documentclass{standalone}
\usepackage{pgfplots}
\usepgflibrary{arrows.meta}
\usepackage{emerald}
\pgfplotsset{
xkcd/.style={
decoration={
View divideby3.c
#include <stdio.h>
#include <stdlib.h>
#if RUN_ME_AS_SH_SCRIPT_TO_BUILD_ME
filename=$0
extension="${filename##*.}"
filename="${filename%.*}"
case $0 in
*.c) ;;
sh) echo 'Run as "sh $0", not "sh < $0"' >&2; exit 1;;
@mohamed
mohamed / texliveonfly.py
Created Feb 11, 2019
TeXLive on the fly
View texliveonfly.py
#!/usr/bin/env python
# default options; feel free to change!
defaultCompiler = "pdflatex"
defaultArguments = "-synctex=1 -interaction=nonstopmode"
defaultSpeechSetting = "never"
#
# texliveonfly.py (formerly lualatexonfly.py) - "Downloading on the fly"
# (similar to miktex) for texlive.
@mohamed
mohamed / fft.cc
Last active Feb 28, 2019
KISS implementation of the Cooley-Tukey recursive FFT algorithm
View fft.cc
#if RUN_ME_AS_SH_SCRIPT_TO_BUILD_ME
filename=$0
extension="${filename##*.}"
filename="${filename%.*}"
case $0 in
*.cc) ;;
sh) echo 'Run as "sh $0", not "sh < $0"' >&2; exit 1;;
*) echo 'Filename must end in ".cc"' >&2; exit 1;;
esac
echo "Compiling $0..."
View tmux-session
#!/usr/bin/env bash
# Save and restore the state of tmux sessions and windows.
# TODO: persist and restore the state & position of panes.
set -e
dump() {
local d=$'\t'
tmux list-windows -a -F "#S${d}#W${d}#{pane_current_path}"
}
You can’t perform that action at this time.