Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View tomislacker's full-sized avatar

Ben Tomasik tomislacker

View GitHub Profile
@tomislacker
tomislacker / buildStatic.sh
Created February 14, 2014 18:09
Building a statically linked suite of git/git binaries for deployment on 32bit hosts
#!/bin/bash
cd $(dirname $0)
LOG_PREFIX=build-static
LOG_STDOUT=${LOG_PREFIX}.stdout
LOG_STDERR=${LOG_PREFIX}.stderr
REMOVE_TARGET_DIR=n
SOURCE_MAKE_CONF=y
param (
[ValidateNotNullOrEmpty()]
[string] $ScriptPath,
[ValidateNotNullOrEmpty()]
[string] $TaskName
# Pass in as many arguments as you want....
)
# Setup error handling.
Trap
@tomislacker
tomislacker / download_huzheng.org.sh
Created February 17, 2021 21:20
Quick hack to download and extract all dictionaries from huzheng.org for `sdcv`
#!/bin/bash
set -exo pipefail
HOST=http://download.huzheng.org/dict.org/
if [ -z "$STARDICT_DATA_DIR" ]
then
echo >&2 "Error: STARDICT_DATA_DIR not set!"
exit 1
@tomislacker
tomislacker / php_predefined_classes.md
Last active June 11, 2020 18:40
PHP Pre-Defined Classes

PHP Pre-Defined Classes

This gist was something I did quickly in order to see what other built-in exception types I could throw.

PHP Version

PHP 5.4.36-pl0-gentoo (cli) (built: Dec 29 2014 22:12:26) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
@tomislacker
tomislacker / es_test.py
Last active January 31, 2020 14:16
Test ElasticSearch Connectivity
"""
Simple test for checking if an EC2 instance or ECS task can access an
ElasticSearch domain. This was mainly lifted from the AWS documentation:
https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-request-signing.html#es-request-signing-python
To use this, first the requisite libraries must be available:
$ pip install -U \
boto3 \
elasticsearch \
requests \
@tomislacker
tomislacker / stack.yml
Created October 30, 2019 14:48
2019-10-30 Dynamic Reference Test
---
AWSTemplateFormatVersion: 2010-09-09
Description: |
testing dynamic references
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html
Parameters:
AMIParameterName:
#Type: 'AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>'
Type: String
@tomislacker
tomislacker / example.yml
Last active September 12, 2019 14:41
CloudFormation - Search & Replace Custom Resource
---
AWSTemplateFormatVersion: 2010-09-09
Description: Testing something
Resources:
R1:
Type: Custom::StringReplacement
Properties:
ServiceToken: !ImportValue cfn-helpers:Replace
Find: '-test'
@tomislacker
tomislacker / rateLimitDecorator.py
Created July 17, 2019 12:51 — forked from gregburek/rateLimitDecorator.py
Rate limiting function calls with Python Decorators
import time
def RateLimited(maxPerSecond):
minInterval = 1.0 / float(maxPerSecond)
def decorate(func):
lastTimeCalled = [0.0]
def rateLimitedFunction(*args,**kargs):
elapsed = time.clock() - lastTimeCalled[0]
leftToWait = minInterval - elapsed
if leftToWait>0:
@tomislacker
tomislacker / output.md
Last active July 15, 2019 13:48
Python Nested Generators with `yield from` Syntax (>=Python.3.3)

TIL about the yield from syntax introduced in >=Python-3.3

In [6]: def f1(p): 
   ...:     yield f'{p}1' 
   ...:     yield f'{p}2' 
   ...:      
   ...:                                                                         

In [7]: def f2(): 
@tomislacker
tomislacker / about.md
Last active April 4, 2019 13:59
Python logging Module Not Showing All Levels
  • Inspired by this gist.
  • Supporting documentation
  • I made a new gist because I wanted to have a more complete example that compared what happens without using that solution versus using it.