Skip to content

Instantly share code, notes, and snippets.

View mohammedi-haroune's full-sized avatar

Haroune Mohammedi mohammedi-haroune

  • BigMama Technologies
View GitHub Profile
@synther
synther / gist:d376100a8bae896d0caf
Last active January 10, 2022 21:39
linux signals cheat sheet
Signal Value Action Comment
SIGHUP 1 Term Hangup detected on controlling terminal or death of controlling process
SIGINT 2 Term Interrupt from keyboard
SIGQUIT 3 Core Quit from keyboard
SIGILL 4 Core Illegal Instruction
SIGABRT 6 Core Abort signal from abort(3)
SIGFPE 8 Core Floating point exception
SIGKILL 9 Term Kill signal
SIGSEGV 11 Core Invalid memory reference
SIGPIPE 13 Term Broken pipe: write to pipe with no readers
@willwest
willwest / GridCV_scores_printer.py
Last active January 27, 2023 11:32
Export a CSV file of GridSearchCV scores.
import csv
import numpy as np
from sklearn.grid_search import GridSearchCV
def print_GridCV_scores(gs_clf, export_file):
'''Exports a CSV of the GridCV scores.
gs_clf: A GridSearchCV object which has been fitted
export_file: A file path
@mucaho
mucaho / src.YOUR_CODE.scala
Created February 13, 2014 10:42
Akka Actors to be executed in Swing / JavaFX thread - based on Victor Klang's [Swing Actors](https://gist.github.com/viktorklang/2422443)
// After that we just create the GUI Actors with a Props with the correct dispatcher set:
val javaFxActor = context.actorOf(Props[JavaFxActor].withDispatcher("javafx-dispatcher"), "javaFxActor")
val swingActor = context.actorOf(Props[SwingActor].withDispatcher("swing-dispatcher"), "swingActor")
// Done! Now all messages processed by the new actor will be executed by the Swing/JavaFX Event Dispatch Thread, enjoy!
@dhrrgn
dhrrgn / cmd.py
Last active December 6, 2024 14:45
Running a command in Python and optionally processing the output in realtime.
import shlex
import subprocess
import sys
def run_cmd(cmd, callback=None, watch=False):
"""Runs the given command and gathers the output.
If a callback is provided, then the output is sent to it, otherwise it
is just returned.
@techniq
techniq / audit_mixin.py
Created March 16, 2013 01:05
Useful SQLAlchemy Mixins
from datetime import datetime
from sqlalchemy import Column, Integer, DateTime, ForeignKey
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declared_attr
from flask_security import current_user
class AuditMixin(object):
created_at = Column(DateTime, default=datetime.now)
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now)
@KartikTalwar
KartikTalwar / Documentation.md
Last active February 28, 2025 10:57
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
@sathishmanohar
sathishmanohar / recover_grub_2.sh
Created May 21, 2012 17:15
Recovering GRUB 2 Boot Loader - Steps and Instructions
# This is text format of the instructions shown in the below Youtube video
# http://www.youtube.com/watch?v=ajs9rO5upZA
# First get a ubuntu Live CD or USB Stick and boot from it
# Check all the Hard disk and Partitions using following command
sudo fdisk -l # Now take a note of the partition, on which linux is installed which may be like: /dev/sda1
# 3. Mount the partition where you need to install GRUB 2 (Hard disk partition)
# Now the file system appears in nautaulis and command line is not file system of Hard disk
@dansimau
dansimau / ping-csv.sh
Created December 23, 2011 11:01
Ping a host and output each reply in CSV format
#!/bin/bash
#
# Do a ping and output results as CSV.
#
# [email protected]
# 2011-12-23
#
if [ $# -lt 1 ]; then
echo "Usage: $0 [--add-timestamp] <ping host>"
@drio
drio / linearRegCostFunction.m
Created November 18, 2011 21:42
Nice way to vectorize the gradient terms when working on linear regression
function [J, grad] = linearRegCostFunction(X, y, theta, lambda)
%LINEARREGCOSTFUNCTION Compute cost and gradient for regularized linear
%regression with multiple variables
% [J, grad] = LINEARREGCOSTFUNCTION(X, y, theta, lambda) computes the
% cost of using theta as the parameter for linear regression to fit the
% data points in X and y. Returns the cost in J and the gradient in grad
% Initialize some useful values
m = length(y); % number of training examples