Skip to content

Instantly share code, notes, and snippets.

View remove_dups.js
db.NASA_MCDAODHD.aggregate([
{ "$group": {
"_id": { "uid": "$loc", "sid": "$dt" },
"dups": { "$push": "$_id" },
"count": { "$sum": 1 }
}},
{ "$match": { "count": { "$gt": 1 } }}
]).forEach(function(doc) {
doc.dups.shift();
db.NASA_MCDAODHD.remove({ _id: { "$in": doc.dups } });
@marvell
marvell / Dockerfile
Created Nov 30, 2015
Dockerfile tips
View Dockerfile
# Отключаем любые promt
ENV DEBIAN_FRONTEND noninteractive
# Удаляем мусор из имиджа
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Использование glibc для alpine
FROM alpine:3.2
RUN apk --update add curl ca-certificates && \
curl -Ls https://circle-artifacts.com/gh/andyshinn/alpine-pkg-glibc/6/artifacts/0/home/ubuntu/alpine-pkg-glibc/packages/x86_64/glibc-2.21-r2.apk > /tmp/glibc-2.21-r2.apk && \
@marvell
marvell / tile_hash.go
Created Aug 4, 2015
Get tile hash by ZXY
View tile_hash.go
func getTileHash(z, x, y int) int64 {
positions := make(map[int][2]int)
for currentZoom := 1; currentZoom <= z; currentZoom++ {
tileSize := int(math.Pow(2, float64(z-currentZoom)))
centerX, centerY := tileSize-1, tileSize-1
if currentZoom > 1 {
n := int(math.Pow(2, float64(currentZoom-1)))
centerX += positions[currentZoom-1][0] * n
@marvell
marvell / gist:01d053ebd2090c8b056a
Created Jun 28, 2015
enable ability to select text in QuickLook
View gist:01d053ebd2090c8b056a
defaults write com.apple.finder QLEnableTextSelection -bool true
killall Finder
View gist:b6d4c02fa29f6c8c002a
docker run --name=redis -d redis
docker run --name=postgres -e POSTGRES_PASSWORD=secret -d postgres
docker exec postgres createdb -U postgres -E utf-8 sentry
docker run --rm -it --link=postgres:postgres --link=redis:redis -v $(pwd):/home/user/.sentry sentry sentry upgrade
docker run --name=sentry --env="VIRTUAL_HOST=sentry.ndr.su" --link=postgres:postgres --link=redis:redis -v $(pwd):/home/user/.sentry -d sentry
docker run --name=sentry-celery --link=postgres:postgres --link=redis:redis -v $(pwd):/home/user/.sentry -d sentry sentry celery worker -B
@marvell
marvell / remove_apt_cache
Created May 18, 2015
Remove APT cache (for Dockerfile)
View remove_apt_cache
apt-get clean autoclean
apt-get autoremove --yes
rm -rf /var/lib/{apt,dpkg,cache,log}/
View gist:b87df6598e5f3ac3f4a2
#!/usr/bin/env bash
set -x
pid=0
# SIGUSR1-handler
my_handler() {
echo "my_handler"
}
@marvell
marvell / tunneling_over_ssh
Created Apr 30, 2015
Проброс портов с удаленной машинки на локальную через SSH
View tunneling_over_ssh
$ ssh -f -N -L 9906:127.0.0.1:3306 user@database.example.com
@marvell
marvell / rvm_paths.sh
Created Jun 13, 2014
Load RVM paths into .bashrc file
View rvm_paths.sh
# Load RVM into a shell session as a function
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
# First try to load from a user install
source "$HOME/.rvm/scripts/rvm"
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
# Then try to load from a root install
source "/usr/local/rvm/scripts/rvm"
else
printf "ERROR: An RVM installation was not found.\n"
fi