Skip to content

Instantly share code, notes, and snippets.

View oss6's full-sized avatar

Ossama Edbali oss6

View GitHub Profile
@oss6
oss6 / lcg.py
Created December 22, 2013 16:42
Python implementation of the LCG (Linear Congruential Generator) for generating pseudo-random numbers.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import random as rnd
import numpy as np
from PIL import Image
from itertools import cycle
def main():
@oss6
oss6 / simple_parser.py
Created December 22, 2013 16:45
A simple parser implemented in Python.
class Parser:
def __init__(self, infix):
self.__infix = infix
self.__postfix = ""
self.__operators = ['+', '-', '*', '/', '^']
def parse(self):
self.__infix_to_postfix()
return self.__eval_postfix()
@oss6
oss6 / spatial_analysis.R
Created April 19, 2014 19:14
Una guida passo-passo dei principali comandi per l'analisi statistica dei dati spaziali
# ===============================================
# === ANALISI SPAZIALE CON R ===
# === AUTHORS: Edbali Ossama, Gazzini Thommy ===
# ===============================================
# =========================================
# === PARTE 1: VISUALIZZAZIONE DATASETS ===
# =========================================
# Carica dataset "meuse" (fiume Mosa)
import scipy
def PoissonPP( rt, Dx, Dy=None ):
'''
Determines the number of events `N` for a rectangular region,
given the rate `rt` and the dimensions, `Dx`, `Dy`.
Returns a <2xN> NumPy array.
'''
if Dy == None:
Dy = Dx
@oss6
oss6 / up
Created January 12, 2015 23:18
Shell function to easily go up through the directory tree without all those dots (cd ../../../../ ---> up 4)
#!/bin/bash
function up() {
if [ $# -ne 1 ]
then
echo "You must provide one argument. e.g. 'up 4'"
fi
START=1
END=$1
@oss6
oss6 / dot.py
Created March 25, 2015 21:20
Gets the value of a nested dictionary specified by the path
def get_prop(d, path):
"""
Gets the value of a nested dictionary specified by the path
d: the dictionary to search recursively
path: a string path
"""
if d is None or not isinstance(d, dict) or not path:
return d
$ mkdir awesome_website
$ cd awesome_website
$ statico
==== CREATE SITE ====
✓ settings.json
✓ atom.xml
✓ Static assets
✓ Templates
@oss6
oss6 / pstorm_array_to_obj
Created September 1, 2015 13:24
PHP Storm: replace array access with object access
NB: Ensure that the "Regex" checkbox is checked.
In the "replace what" bar (replace single-quotes with double-quotes if necessary):
\$var_name\['(.+?)']
In the "replace to" bar:
\\$var_name->$1
@oss6
oss6 / pages.py
Created May 17, 2020 16:14
Simple paging utility for reading long text in the terminal.
import curses
import math
import sys
import textwrap
def print_page(screen, pages, index):
screen.clear()
screen.addstr(0, 30, f'({index + 1})')
@oss6
oss6 / main.R
Last active May 1, 2023 20:37
LC/MS Feature detection using xcms' centwave
# -------------------------------------------------------------------------------------------------
# Adapted from https://www.bioconductor.org/packages/release/bioc/vignettes/xcms/inst/doc/xcms.html
# The below example uses a subset of the data in the investigation of the metabolic consequences
# of knocking out the fatty acid amide hydrolase (FAAH) gene in mice.
if (!require("BiocManager", quietly = TRUE)) {
install.packages("BiocManager")
}
if (!("xcms" %in% rownames(installed.packages()))) {