Skip to content

Instantly share code, notes, and snippets.

Jonathan Kosgei jonathan-kosgei

Block or report user

Report or block jonathan-kosgei

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jonathan-kosgei
jonathan-kosgei / python-object-size.py
Created Apr 13, 2018
Get the size of any object in Python
View python-object-size.py
import sys
def get_size(obj, seen=None):
"""Recursively finds size of objects"""
size = sys.getsizeof(obj)
if seen is None:
seen = set()
obj_id = id(obj)
if obj_id in seen:
return 0
@jonathan-kosgei
jonathan-kosgei / timer.py
Last active Dec 6, 2019
Python Decorator to Time a Function
View timer.py
""" A simple decorator that times the duration of a function's execution. More info on Decorators at https://pythonconquerstheuniverse.wordpress.com/2009/08/06/introduction-to-python-decorators-part-1/"""
import timeit
def timer(function):
def new_function():
start_time = timeit.default_timer()
function()
elapsed = timeit.default_timer() - start_time
print('Function "{name}" took {time} seconds to complete.'.format(name=function.__name__, time=elapsed))
return new_function()
View keybase.md

Keybase proof

I hereby claim:

  • I am jonathan-kosgei on github.
  • I am jkosgei (https://keybase.io/jkosgei) on keybase.
  • I have a public key whose fingerprint is 4A3A EC85 E348 E5A8 4FD5 E82B 1C9F 43F8 656B 81FF

To claim this, I am signing this object:

@jonathan-kosgei
jonathan-kosgei / pypi.md
Created Oct 25, 2017
deploying to pypi
View pypi.md
git push origin master
git tag 1.3 -m "desc"
git push --tags origin master
python setup.py sdist upload
@jonathan-kosgei
jonathan-kosgei / stats.txt
Created Sep 8, 2017
API Stats for ipdata.co
View stats.txt
./hey -m GET -n 1000000 https://ipdata.co -more
Summary:
Total: 476.9207 secs
Slowest: 5.0308 secs
Fastest: 0.0010 secs
Average: 0.0225 secs
Requests/sec: 2096.7846
Total data: 315238010 bytes
Size/request: 315 bytes
View container-logs.txt
ERROR: extension "pgcrypto" already exists
Buildfile: /opt/dspace/dspace/target/dspace-installer/build.xml
init_installation:
[mkdir] Created dir: /dspace/bin
[mkdir] Created dir: /dspace/config
[mkdir] Created dir: /dspace/lib
[mkdir] Created dir: /dspace/etc
[mkdir] Created dir: /dspace/webapps
[mkdir] Created dir: /dspace/triplestore
View README.md

Getting Started

kubectl apply -f storageclass.yml
kubectl apply -f neo4j-service.yml
kubectl apply -f neo4j-statefulset.yml
@jonathan-kosgei
jonathan-kosgei / plugin.php
Created Aug 15, 2017
Wordpress enqueue scripts
View plugin.php
function ensure_select2() {
wp_enqueue_style( 'select2', plugin_dir_url( __FILE__ ) . 'assets/css/select2.min.css' );
wp_enqueue_script( 'select2', plugin_dir_url( __FILE__ ) . 'assets/js/select2.js', array(), '1.0.0', true );
}
add_action( 'admin_head' , 'ensure_select2' );
@jonathan-kosgei
jonathan-kosgei / functions.php
Created Aug 15, 2017
Woocommerce auto update cart on quantity change
View functions.php
add_action( 'wp_footer', 'cart_update_qty_script' );
function cart_update_qty_script() {
if (is_cart()) :
?>
<script>
jQuery('div.woocommerce').on('change', '.qty', function(){
jQuery("[name='update_cart']").trigger("click");
});
</script>
<?php
@jonathan-kosgei
jonathan-kosgei / README.md
Last active Dec 19, 2018
Deploy PHP site to AWS Elasticbeanstalk with Bitbucket Pipelines
View README.md

ElasticBeanstalk on AWS

Getting Started

To deploy a new Magento store automatically via Bitbucket CI. Follow the following steps.

1. Set the following environment variables for the bitbucket repo with the magento store source code

AWS_ACCESS_KEY_ID=
You can’t perform that action at this time.