Skip to content

Instantly share code, notes, and snippets.

@rstruber
rstruber / elasticsearch-update-settings.py
Created August 25, 2015 16:30
Example of how to use curator and elasticsearch python api to update index settings
import elasticsearch
import curator
import json
client = elasticsearch.Elasticsearch()
indices = curator.get_indices(client)
# Filter anything older than or equal to 3 days
_filter = curator.build_filter(kindOf='newer_than', value=3, time_unit='days', timestring='%Y.%m.%d')
indices = curator.apply_filter(indices, **_filter)
@tonyxh
tonyxh / SimpleAuthServer.py
Last active September 5, 2016 20:34 — forked from fxsjy/SimpleAuthServer.py
SimpleAuthServer: A SimpleHTTPServer with authentication
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
import sys
import base64
key = ""
class AuthHandler(SimpleHTTPRequestHandler):
''' Main class to present webpages and authentication. '''
def do_HEAD(self):
@mbbx6spp
mbbx6spp / ALTERNATIVES.adoc
Last active January 7, 2025 16:25
Super quick list of alternatives to Jira and/or Confluence, Stash, Crucible, etc.
@jaceklaskowski
jaceklaskowski / deployment-tool-ansible-puppet-chef-salt.md
Last active February 20, 2025 16:38
Choosing a deployment tool - ansible vs puppet vs chef vs salt

Requirements

  • no upfront installation/agents on remote/slave machines - ssh should be enough
  • application components should use third-party software, e.g. HDFS, Spark's cluster, deployed separately
  • configuration templating
  • environment requires/asserts, i.e. we need a JVM in a given version before doing deployment
  • deployment process run from Jenkins

Solution

@damzam
damzam / lru_cache.py
Created June 12, 2015 16:28
Implement a simple LRUCache in Python
#!/usr/bin/env python
"""
Python's OrderedDict is an ideal data structure
to create an LRU cache
"""
from collections import OrderedDict
class LRUCache(object):
@petervanderdoes
petervanderdoes / zfs_health.sh
Last active March 18, 2025 23:23
ZFS Health Check Script
#! /usr/local/bin/bash
#
# Calomel.org
# https://calomel.org/zfs_health_check_script.html
# FreeBSD 9.1 ZFS Health Check script
# zfs_health.sh @ Version 0.15
# Check health of ZFS volumes and drives. On any faults send email. In FreeBSD
# 10 there is supposed to be a ZFSd daemon to monitor the health of the ZFS
# pools. For now, in FreeBSD 9, we will make our own checks and run this script
@AmirHooshangi
AmirHooshangi / Math
Created June 7, 2015 12:00
What are your "Must read Math Books for programmers"
1. Concrete mathematics _ a foundation for computer science-Addison-Wesley
2. Ralph_P._Grimaldi_Discrete_and_Combinatorial_Math
3. Joel S. Cohen-Computer Algebra and Symbolic Computation_ Mathematical Methods (2003)
4. Joel S. Cohen-Computer Algebra and Symbolic Computation_ Elementary Algorithms (2002)
@vsouza
vsouza / .bashrc
Last active April 20, 2025 21:15
Golang setup in Mac OSX with HomeBrew. Set `GOPATH` and `GOROOT` variables in zshell, fish or bash.
# Set variables in .bashrc file
# don't forget to change your path correctly!
export GOPATH=$HOME/golang
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
@darekkay
darekkay / intellij-monokai-theme.xml
Last active February 19, 2025 03:01
Monokai Theme for JetBrains IDEs (IntelliJ IDEA, Webstorm, PhpStorm, PyCharm etc.)
<scheme name="Eclectide Monokai" version="142" parent_scheme="Default">
<colors>
<option name="ADDED_LINES_COLOR" value="295622" />
<option name="ANNOTATIONS_COLOR" value="b2c0c6" />
<option name="CARET_COLOR" value="bbbbbb" />
<option name="CARET_ROW_COLOR" value="" />
<option name="CONSOLE_BACKGROUND_KEY" value="1c1c1c" />
<option name="FILESTATUS_ADDED" value="629755" />
<option name="FILESTATUS_DELETED" value="6c6c6c" />
<option name="FILESTATUS_IDEA_FILESTATUS_DELETED_FROM_FILE_SYSTEM" value="6c6c6c" />
@kelvinn
kelvinn / cmd.sh
Created July 24, 2014 02:55
Example of using Apache Bench (ab) to POST JSON to an API
# post_loc.txt contains the json you want to post
# -p means to POST it
# -H adds an Auth header (could be Basic or Token)
# -T sets the Content-Type
# -c is concurrent clients
# -n is the number of requests to run in the test
ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/