Skip to content

Instantly share code, notes, and snippets.

@robertpainsi
robertpainsi / commit-message-guidelines.md
Last active September 26, 2025 20:31
Commit message guidelines

Commit Message Guidelines

Short (72 chars or less) summary

More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).

Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
@calebreister
calebreister / csv.lua
Created April 28, 2017 17:21
Lua script that converts a CSV file to the LaTeX tabular format
--To include this file, use
--dofile('csv.lua') or require('csv')
--Function to convert a *SV file to a Lua array
--file: the name of the file to read
--delim: the delimeter (default ',')
function dataToTable(file, delim)
--Set initial values
if delim == nil then --allow delim to be optional
delim = ','
@jaketame
jaketame / logging_subprocess.py
Created April 28, 2017 13:05
Python subprocess logging to logger from stdout/stderr
#!/usr/local/bin/python3
import logging, select, subprocess
LOG_FILE = "test.log"
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO,filename=LOG_FILE,format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
def logging_call(popenargs, **kwargs):
process = subprocess.Popen(popenargs, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
@ncullen93
ncullen93 / multisampler.py
Created April 27, 2017 01:22
MultiSampler for Pytorch
class MultiSampler(Sampler):
"""Samples elements more than once in a single pass through the data.
This allows the number of samples per epoch to be larger than the number
of samples itself, which can be useful for data augmentation.
"""
def __init__(self, nb_samples, desired_samples, shuffle=False):
self.data_samples = nb_samples
self.desired_samples = desired_samples
self.shuffle
# data from http://ec.europa.eu/eurostat/web/gisco/geodata/reference-data/population-distribution-demography/geostat
# Originally seen at http://spatial.ly/2014/08/population-lines/
# So, this blew up on both Reddit and Twitter. Two bugs fixed (southern Spain was a mess,
# and some countries where missing -- measure twice, submit once, damnit), and two silly superflous lines removed after
# @hadleywickham pointed that out. Also, switched from geom_segment to geom_line.
# The result of the code below can be seen at http://imgur.com/ob8c8ph
library(tidyverse)
@Mikuana
Mikuana / gist:de5eb835eb032904b44e1e7869d795c0
Created March 27, 2017 12:09
Teradata JDBC URL for use in PyCharm data connection
jdbc:teradata://{host::localhost}/[\?<&,user={user},password={password},database={database}>]
@kmindi
kmindi / .gitlab-ci.yml
Last active November 3, 2021 12:20
GitLab CI Configuration file for latex with building files in subdirectory with latex runner
compile_pdf:
image: kmindi/latex-docker
script:
- latexmk -C -cd -outdir="M2" -auxdir="M2" M2/M2.tex
- latexmk -lualatex -pdf -cd -outdir="M2" -auxdir="M2" M2/M2.tex
artifacts:
paths:
- "M2/M2.pdf"
expire_in: 1 week
except:
# Regular expressions I've used to convert a tex file using Biblatex to apacite:
(?s)cites{([^{}]*?)}{
cites{\1,
(?s)cites{([^{}]*?)}\n{
cites{\1,
@alex-senov
alex-senov / ranking_measures_mapK_ndcg
Last active December 17, 2019 07:20
Метрики качества ранжирования
<script type="text/javascript" src="https://stackedit.io/libs/MathJax/MathJax.js?config=TeXAMS_HTML></script>
> Written with [StackEdit](https://stackedit.io/).
# Метрики качества ранжирования
Ранжирование --- это задача сортировки набора элементов из соображения их *релевантности*. Чаще всего релевантность понимается по отношению к какому-то объекту. Например, в задаче информационного поиска объект --- это запрос, элементы --- всевозможные документы (ссылки на них), а релевантность --- соответствие документа запросу, в задаче рекомендаций же объект --- это пользователь, элементы --- тот или иной контент (товары, видео, музыка), а релевантность --- вероятность того, что пользователь воспользуется данным контентом.
Формально, результат алгоритма ранжирования --- это упорядоченный список элементов фиксированного размера (обозначим его K): $\{i_1, ..., i_K\}$. При проверке результатов алгоритма ранжирования среди предсказанных элементов $\{i_1, ..., i_K\}$ некоторые могут оказаться релевантными (пользовате
@mesgarpour
mesgarpour / YeoJohnson.py
Last active October 13, 2022 11:53
Yeo-Johnson Transformation
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import warnings
import numpy as np
import pandas as pd
import sys
__author__ = "Mohsen Mesgarpour"
__copyright__ = "Copyright 2016, https://github.com/mesgarpour"
__credits__ = ["Mohsen Mesgarpour"]