Skip to content

Instantly share code, notes, and snippets.

View AlmightyOatmeal's full-sized avatar

Jamie Ivanov AlmightyOatmeal

View GitHub Profile
from pyelasticsearch import ElasticSearch, ElasticHttpNotFoundError
from pyparsing import *
import unittest
ELASTICSEARCH_INDEX = 'myindex'
ELASTICSEARCH_URL = 'http://localhost:9200/'
es = ElasticSearch(ELASTICSEARCH_URL)
@AlmightyOatmeal
AlmightyOatmeal / digitalocean-promo-code-summer-2017.md
Created August 12, 2017 23:57
Digital Ocean Promo Code for Summer 2017

Digital Ocean Promo Code for June / July / August 2017

Save $25 for your Cloud Computing Solution with Digital Ocean.

How to get the Discount?

1.) Use this link to Sign Up and save your first $10.

2.) Enter the Promocode LOWENDBOX when you choose your payment method and get another $15 discount.

@AlmightyOatmeal
AlmightyOatmeal / FreeBSD_node_monit.md
Created September 15, 2017 14:35 — forked from fdelbos/FreeBSD_node_monit.md
FreeBSD 10 Nodejs setup with nginx, mongo and monit

FreeBSD 10 Nodejs setup with nginx, mongodb, redis and monit

This my receipe for installing a complete nodejs server on FreeBSD 10. The parameters used in this configuration are for a very small private server that I use for demo purpose only, so for a production server, you should somehow set the limits in pair with your ressources.

I use monit so I don't have to write rc scripts for node and it should take care of process lifecycle management for me. Alternatives exists such as supervisord or circus.

Installing mongodb

@AlmightyOatmeal
AlmightyOatmeal / tunetest.py
Created September 23, 2017 20:39 — forked from simeonmiteff/tunetest.py
Simple rtl_tcp client to test rapid tuning
#! /usr/bin/env python2
# Small test client for rtl_tcp
# Simeon Miteff <simeon.miteff@gmail.com>
# Thu Sep 27 09:28:55 SAST 2012
import socket
import struct
import time
SET_FREQUENCY = 0x01
SET_SAMPLERATE = 0x02
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2015 Martin Raspaud
# Author(s):
# Martin Raspaud <martin.raspaud@smhi.se>
# This program is free software: you can redistribute it and/or modify
@AlmightyOatmeal
AlmightyOatmeal / gtb
Created October 24, 2017 18:37 — forked from dschuetz/gtb
Hackish script to compute Google Authenticator tokencodes and launch a Tunnelblick VPN with the appropriate computed password+tokencode
#!/usr/bin/python
import hmac, struct, time, base64, hashlib # for totp generation
import re, sys, subprocess # for general stuff
from getopt import getopt, GetoptError # pretending to be easy-to-use
#
# gtb - Google(auth) + Tunnelblick
#
@AlmightyOatmeal
AlmightyOatmeal / selenium-screenshotting.md
Created November 20, 2017 18:35 — forked from dannguyen/selenium-screenshotting.md
Using Selenium and Python to screenshot a javascript-heavy page

Using Selenium and Python to screenshot a javascript-heavy page

As websites become more JavaScript heavy, it's harder to automate things like screenshotting for archival purposes. I've seen examples and suggestions to use PhantomJS for visual testing/archiving of websites, but have run into issues such as the non-rendering of webfonts. I've never tried out Selenium until today...and while I'm not thinking about performance implications yet, Selenium seems far more accurate than PhantomJS...which makes sense since it actually opens a real browser. And it's not too hard to script to do complex interactions: here's an [example of how to log in to Twitter, write a tweet, upload an image, and send a tweet via Selenium and DOM element selection](https://gist.github.com/dannguyen/8a6fa49253c1d6a0eb92

@AlmightyOatmeal
AlmightyOatmeal / phantom.py
Created November 20, 2017 18:46 — forked from jsok/phantom.py
Use PhantomJS and Python Selenium bindings to take screenshots of websites.
import StringIO
from selenium import webdriver
from PIL import Image
# Install instructions
#
# npm install phantomjs
# sudo apt-get install libjpeg-dev
# pip install selenium pillow
@AlmightyOatmeal
AlmightyOatmeal / Python.SignalFx.SignalFlow_Wrapper.py
Last active October 20, 2020 19:15
Wrapper for SignalFx's Python client library for executing SignalFlow programs and returning a dictionary object that can be serialized to JSON. This also features exception handling to retry program text execution which is especially helpful for long-running SignalFlow programs that should be restarted in the event of a failure.
"""
Disclaimer
==========
This has been designed as a solution for a specific task, or set of tasks, by the code author which is outside
the locus of SignalFx supportability. This code is provided as-is and if any support is needed then it should
be provided by the original code author on a best-effort only basis; it cannot be supported through break/fix
support channels.
Synopsis
@AlmightyOatmeal
AlmightyOatmeal / Python.JSON.py
Last active February 1, 2024 20:01
Pretty-print a dictionary/list structure in JSON while having the option to use a custom JSON encoder to help with special objects that don't support serialization, such as converting 'datetime' objects to an ISO-formatted string.
import datetime
import decimal
import json
import re
class CustomJSONEncoder(json.JSONEncoder):
"""Custom JSON encoder that does things that shouldn't need to be done."""
def default(self, obj):