Skip to content

Instantly share code, notes, and snippets.

@nowox
nowox / git-diffbeyond
Created March 24, 2015 13:20
Improve workflow with Git and BeyondCompare
#!/usr/bin/bash
#File: git-diffbeyond
#Author: Yves Chevallier <nowox@x0x.ch>
#Date: 2015-03-24 Tue 02:16 PM
head="HEAD~1"
# Create temporary folder
OUT="$(mktemp -d)"
# Copy current files into this folder
@nowox
nowox / plenty.py
Created April 28, 2016 18:31
Python script that creates plenty of files and can alter them
#!/usr/bin/python
import os
import loremipsum
import random
import bisect
import numpy
import textwrap
class RandomWeight:
def __init__(self, weight):
### Keybase proof
I hereby claim:
* I am nowox on github.
* I am nowox (https://keybase.io/nowox) on keybase.
* I have a public key ASCn7HlZniQK49Xt9ayx717TlY68s7kLY2v-npo8f0QKCgo
To claim this, I am signing this object:
#!/usr/bin/python
import cProfile, pstats, StringIO
from random import choice, random
import copy
import collections
class DataGenerator(object):
depth = 0
#!/usr/bin/env python
"""Update of new names in source code after massive file rename onto a Git repository.
This script considers:
- The script is located at the root of the Git repository
- The head of the branch where the files were renamed is checkout
- This branch as a common ancestor with the master
- This common ancestor is used for the diff
@nowox
nowox / mintty.log
Created March 9, 2017 15:26
Mintty issue with italic and double quotes
]10;#d0d0d0]11;#151515]12;#FD9D4F]4;262;#FD9D4F]4;0;#252525]4;8;#4a5a5a]4;1;#AC4142]4;9;#b26364]4;2;#90A959]4;10;#A6BB7B]4;3;#F4BF75]4;11;#F8D5A5]4;4;#6A9FB5]4;12;#8CB5C6]4;5;#AA759F]4;13;#BE95B5]4;6;#75B5AA]4;14;#97C7BE]4;7;#D0D0D0]4;15;#F5F5F5[5 q(0) ~ $ vi .minttyrc -u NONE
[?1049h[?1h=[?12;25h[?12l[?25h[?25l~ ~ ~ ~ ~ ~
@nowox
nowox / gist:1d0165221ac17a6de071f51c5428b599
Last active March 28, 2017 14:49
Example with Pandas
In [119]: d = {
...: 'test1': {
...: 0: {'a': {'min': 1, 'mid': 12, 'max': 13},
...: 'b': {'min': 2, 'mid': 22, 'max': 23}},
...: 3: {'a': {'min': 3, 'mid': 32, 'max': 33},
...: 'b': {'min': 4, 'mid': 42, 'max': 43}},
...: 8: {'a': {'min': 5, 'mid': 52, 'max': 53},
...: 'b': {'min': 6, 'mid': 62, 'max': 63}},
...: },
...: 'test2': {
In [297]: d = {0: {'foo': {'a': 12.68, 'b': 54.44, 'c': 83.98},
...: 'bar': {'a': 11.73, 'b': 53.34, 'c': 82.93}},
...: 2: {'foo': {'a': 11.12, 'b': 57.99, 'c': 81.05},
...: 'bar': {'a': 10.05, 'b': 56.12, 'c': 80.01}},
...: 1: {'foo': {'a': 13.41, 'b': 54.32, 'c': 82.74},
...: 'bar': {'a': 12.77, 'b': 53.15, 'c': 82.01}}}
In [298]: ds = (pd.DataFrame.from_dict(d, orient='index')
...: .stack().apply(pd.Series)
...: .rename_axis(['experiment', 'setup']))
~ $ cd test
~/test $ git init
git clone --depth=1 --no-checkout ../sub sub
git submodule add ../sub sub
git submodule absorbgitdirs
# note there is no "submodule.sub.sparsecheckout" key
git -C sub config core.sparseCheckout true
echo bar >>.git/modules/sub/info/sparse-checkout
git submodule update subInitialized empty Git repository in /cygdrive/c/Users/Ycr/Home/ppp/test/.git/
~/test $ # I did not find a way to add submodule in 1 step without checking out
0 ~/test $ git init
Initialized empty Git repository in /cygdrive/c/Users/Ycr/Home/test/.git/
0 ~/test $ cat .git/config
[core]
ignorecase = true
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true