Skip to content

Instantly share code, notes, and snippets.

@dholstius
dholstius / merge.SpatialPointsDataFrame.R
Created October 2, 2014 18:58
Merge a SpatialPolygonsDataFrame with a data.frame
merge.SpatialPolygonsDataFrame <- function (x, y, by, ...) {
require(sp)
y <- as.data.frame(y)
if (missing(by)) {
if (is.null(row.names(x@data)) || is.null(row.names(y))) {
warning("[merge.SpatialPolygonsDataFrame] merging by position")
i <- 1:nrow(x@data)
} else {
warning("[merge.SpatialPolygonsDataFrame] merging by row names")
i <- row.names(x@data)
@imranity
imranity / gist:179e0ca33d7c93429ba7
Created February 17, 2015 02:57
Sphinx builder how to fix 'WARNING: Definition list ends without a blank line; unexpected unindent.'
recently i came up with this warning which was failing my job .
The reason this warning happens is that for a multi-line comment/description, you should give '\' after each line except the last line.
so lets i have a doc comment like this:
'this is a test
comment which describes
something about this module.'
Above docstring will obviously in sphinx build job, so correct way is :
'this is a test \
comment which describes \
@mrecos
mrecos / stratifiedCV.r
Last active August 14, 2020 17:50
Stratified K-folds Cross-Validation with Caret
require(caret)
#load some data
data(USArrests)
### Prepare Data (postive observations)
# add a column to be the strata. In this case it is states, it can be sites, or other locations
# the original data has 50 rows, so this adds a state label to 10 consecutive observations
USArrests$state <- c(rep(c("PA","MD","DE","NY","NJ"), each = 5))
# this replaces the existing rownames (states) with a simple numerical index
@tomykaira
tomykaira / white_balance.cpp
Last active June 1, 2023 08:46
Simplest white balance in OpenCV
// The MIT License (MIT)
// Copyright (c) 2015 tomykaira
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON
@lmarkus
lmarkus / README.MD
Last active October 3, 2025 03:29
Extracting / Exporting custom emoji from Slack

Extracting Emoji From Slack!

Slack doesn't provide an easy way to extract custom emoji from a team. (Especially teams with thousands of custom emoji) This Gist walks you through a relatively simple approach to get your emoji out.

If you're an admin of your own team, you can get the list of emoji directly using this API: https://api.slack.com/methods/emoji.list. Once you have it, skip to Step 3

HOWEVER! This gist is intended for people who don't have admin access, nor access tokens for using that list.

Follow along...

@samiraguiar
samiraguiar / MC Cheat Sheet
Last active October 11, 2025 13:28 — forked from maciakl/MC Cheat Sheet
Midnight Commander Cheat Sheet / Shortcuts
Note for newcomers:
In the shortcuts below, "C" stands for CTRL and "A" stands for "ALT". This is a convention
used in the Midnight Commander documentation and was kept here.
You can also use "ESC" instead of "ALT", which is useful on Macbooks.
Main View
---------------------------------------------------------------
- File/directory operations
@alopresto
alopresto / Merging PR for 2 branches
Last active May 15, 2024 15:16
Instructions to merge pull requests for multiple branches (master, support, etc.)
#Steps to merge/close pull requests with two main branches
As NiFi now has a 1.0 (master) and 0.x (support) branch, pull requests (PR) must be applied to both. Here is a step-by-step guide for committers to ensure this occurs for all PRs.
1. Check out the latest master
``` $ git checkout master
$ git pull upstream master
```
2. Check out the PR (example #327). This will be in `detached-HEAD` state. (Note: You may need to edit the `.git/config` file to add the `fetch` lines [below](#fetch))
@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"]
@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\}$ некоторые могут оказаться релевантными (пользовате
# Regular expressions I've used to convert a tex file using Biblatex to apacite:
(?s)cites{([^{}]*?)}{
cites{\1,
(?s)cites{([^{}]*?)}\n{
cites{\1,