Skip to content

Instantly share code, notes, and snippets.

@carlopires
carlopires / ISO639_2.py
Created October 4, 2011 16:06 — forked from austing/gist:779243
Python dict with ISO-639-2 language codes
# -o- coding: utf-8 -o-
# ISO639 python dict
# oficial list in http://www.loc.gov/standards/iso639-2/php/code_list.php
ISO639_2 = {
'ab': 'Abkhaz',
'aa': 'Afar',
'af': 'Afrikaans',
'ak': 'Akan',
'sq': 'Albanian',
@brantfaircloth
brantfaircloth / cool_argparse_stuff.py
Created December 7, 2011 16:47
Some cool argparse stuff
class FullPaths(argparse.Action):
"""Expand user- and relative-paths"""
def __call__(self, parser, namespace, values, option_string=None):
setattr(namespace, self.dest, os.path.abspath(os.path.expanduser(values)))
def is_dir(dirname):
"""Checks if a path is an actual directory"""
if not os.path.isdir(dirname):
msg = "{0} is not a directory".format(dirname)
raise argparse.ArgumentTypeError(msg)
@ummels
ummels / mydiss.cls
Last active March 27, 2024 14:56
Class file for my PhD thesis
% Copyright (c) 2010 Michael Ummels <michael@ummels.de>
%
% Permission to use, copy, modify, and/or distribute this software for any
% purpose with or without fee is hereby granted, provided that the above
% copyright notice and this permission notice appear in all copies.
%
% THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
% WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
% MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
% ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
@Brick85
Brick85 / gist:5009046
Last active May 3, 2019 09:35
OpenCV Alpha Blending: Blend two cv::Mat with alpha mask. Poorly optimised.
void blendWithMask(cv::Mat &base, cv::Mat &src, cv::Mat &mask, cv::Mat &out){
char ch = base.channels();
double alpha = 0;
for( int y = 0; y < base.rows; y++ ){
uchar* pBS = base.ptr<uchar>(y);
uchar* pSR = src.ptr<uchar>(y);
uchar* pMK = mask.ptr<uchar>(y);
uchar* pOU = out.ptr<uchar>(y);
for( int x = 0; x < base.cols*ch; x++ ){
int ix = x / ch;
@ChrisWellsWood
ChrisWellsWood / empty_rust_structs.md
Last active November 8, 2023 10:05
Initialising empty structs in Rust.

Initialising Empty Structs in Rust

In C/C++, you can initialise a struct without giving values for any of the fields:

struct Point {
  float x;
  float y;
  float z;
};
@yhilpisch
yhilpisch / 00_cqf_ml_elective.md
Last active February 11, 2024 23:13
Machine Learning for Finance | Dr. Yves J. Hilpisch | CQF Elective | London, 23. May 2017

Machine Learning for Finance

A CQF elective with Dr. Yves J. Hilpisch, The Python Quants GmbH

General resources:

@wilsonsilva
wilsonsilva / undo_last_commit.sh
Created June 21, 2017 15:47
Undo last commit but keep changes
# https://stackoverflow.com/a/44672195/3013522
git reset --soft HEAD~1
@whatupfoo
whatupfoo / 1-orgs-archetype.md
Last active March 12, 2024 06:58
Orgs and Teams Best Practices

Organization archetypes

The intention of this document is to provide some guidance and suggestions to customers who are wondering how they should structure organizations and teams in their GitHub Enterprise environment. The idea isn't to give hard and fast rules on which approach is better than the other, but to give examples of when one approach might be preferable to another depending on the use case.

1. A single organization with direct organization membership for repository access (not teams)

          ________________
          |     Org      |
          |    ______    |
          |   |      |\  |

| | Repo | \ |

@maxwellmlin
maxwellmlin / LPX-Trial-Reset.sh
Created April 14, 2021 03:46
Logic Pro X Trial Reset
mv -v ~/Library/Application\ Support/.lpxuserdata ~/.Trash