Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block Fifan31

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
Fifan31 /
Created Jun 1, 2018
Show largest file in git repo
#set -x
# Shows you the largest objects in your repo's pack file.
# Written for osx.
# @see
# @author Antony Stubbs
class DottedKeyDict(dict):
def get(self, path, default = None):
keys = path.split(".")
val = None
for key in keys:
if val:
if isinstance(val, list):
val = [ v.get(key, default) if v else None for v in val]
Fifan31 / merge_lists.txt
Last active Dec 8, 2016
Python - merge 2 lists
View merge_lists.txt
list1 = ['a', 'c', 'e']
list2 = ['b', 'd', 'f']
list3 = [ item for tmp in zip(list1, list2) for item in tmp]
# list3 = ['a', 'b', 'c', 'd', 'e', 'f']
Fifan31 /
Last active Sep 27, 2016
Shell functions intialisation. Put this script in /etc/profile.d/
while [ $authok -eq 0 ] ; do
echo "Setting proxy environment variables:"
echo -n " Username: "
read -e username
echo -n " Password: "
read -es password
Fifan31 / gist:7c9e2fffdb7a71202cfca7a1e3297e32
Created Jun 7, 2016
Utilisation de avec le typage des données
View gist:7c9e2fffdb7a71202cfca7a1e3297e32 -A IMG.tif -B IMG.tif --B_band=2 --outfile=titi.tif --calc="1.0*((A.astype(float)*A.astype(float))+(B.astype(float)*B.astype(float)))" --type=Float32 --overwrite
Fifan31 / gist:bbb4f57f2e63fe80b7a10f71c721093f
Created Apr 5, 2016
Convert exception stacktrace to String object
View gist:bbb4f57f2e63fe80b7a10f71c721093f
* Creates and returns a {@link java.lang.String} from <code>t</code>’s stacktrace
* @param t Throwable whose stack trace is required
* @return String representing the stack trace of the exception
public String getStackTrace(Throwable t) {
StringWriter stringWritter = new StringWriter();
PrintWriter printWritter = new PrintWriter(stringWritter, true);
Fifan31 /
Created Feb 3, 2016 — forked from pvdb/
List all targets (sometimes incorrectly referred to as "goals") in a GNU Makefile
# this gist can be used to list all targets, or - more correctly - rules,
# that are defined in a Makefile (and possibly other included Makefiles)
# and is inspired by Jack Kelly's reply to a StackOverflow question:
# I also found this script - - which does
# something similar using awk, but it extracts targets from the "static" rules from a single
# Makefile, meaning it ignores any included Makefiles, as well as targets from "dynamic" rules
View Redirect stdout and stderr to a logger in Python
import logging
import sys
class StreamToLogger(object):
Fake file-like stream object that redirects writes to a logger instance.
def __init__(self, logger, log_level=logging.INFO):
self.logger = logger
self.log_level = log_level
import lxml.etree as le
from operator import attrgetter
import os
import tempfile
import difflib
def sortbyid(elem):
'''Function to sort XML elements by id
(where the elements have an 'id' attribute that can be cast to an int)
Fifan31 /
Created Jan 5, 2016 — forked from mammadori/
Python: "source" a shell script and read variables
from subprocess import Popen, PIPE
from os import environ
def source(script, update=True, clean=True):
Source variables from a shell script
import them in the environment (if update==True)
and report only the script variables (if clean==True)
You can’t perform that action at this time.