Skip to content

Instantly share code, notes, and snippets.

View davidlj95's full-sized avatar

David LJ davidlj95

View GitHub Profile
@davidlj95
davidlj95 / mySQL2SQLite3.sh
Last active August 29, 2015 14:14
MySQL2SQLite3.sh
#=============================================================================#
# __ __ _____ ____ _ ___ _____ ____ _ _ _ #
# | \/ | / ____|/ __ \| | |__ \ / ____|/ __ \| | (_) | #
# | \ / |_ _| (___ | | | | | ) | | (___ | | | | | _| |_ ___ #
# | |\/| | | | |\___ \| | | | | / / \___ \| | | | | | | __/ _ \ #
# | | | | |_| |____) | |__| | |____ / /_ ____) | |__| | |____| | || __/ #
# |_| |_|\__, |_____/ \___\_\______| |____| |_____/ \___\_\______|_|\__\___| #
# __/ | #
# |___/ #
# #
@davidlj95
davidlj95 / gaussian_statistics.py
Created January 12, 2017 02:25
Simple script to calculate mean, standard deviation, variance and optionally the gaussian probability for a given target value inside a given set of elements, that can be divided in boolean classes to calculate the statistics for each subset. Was designed as help for calculus in Naïve Bayes algorithm exercises
# Libraries
import math
import sys
# Constants
MIN_ARGS = 1
# Parameters
values = None
values_yes = None
@davidlj95
davidlj95 / keybase.md
Created July 12, 2017 01:05
Proof of identity for keybase.io

Keybase proof

I hereby claim:

  • I am davidlj95 on github.
  • I am davidlj95 (https://keybase.io/davidlj95) on keybase.
  • I have a public key whose fingerprint is D214 E5C6 6C18 EEC5 8B21 11CE 1441 FA43 5DE6 AC64

To claim this, I am signing this object:

@davidlj95
davidlj95 / telegram-msg
Created July 21, 2017 05:37
Allows to send a message to a Telegram contact once configured telegram-cli (vysheng/tg) without entering the telegram-cli and using the contact / group name, not its ide
#!/bin/bash
# Uses telegram-cli to send a message to the given destination
# Usage: ./telegram_msg <DESTINATION> <MESSAGE>
#==============================================================
# Constants
#==============================================================
APP_NAME=telegram_msg
# Name of the app as appears in logs
APP="/usr/local/bin/telegram-cli"
# telegram-cli location
@davidlj95
davidlj95 / block-info.py
Last active July 21, 2017 05:40
Python3 script to obtain interesting data about a Bitcoin block (mainly what it signals) given the block hash, by using RPC calls to bitcoind
#!/usr/bin/env python3
# Description:
# ============
# Script to given a block hash, create a message informing
# if the block signals for BIP-91 / BIP-141
#
# To do that, connects to the local bitcoind node and
# uses RPC calls to get details on that block and what does
# it signal
#
@davidlj95
davidlj95 / block-notify.sh
Created July 21, 2017 05:42
Obtains information about a Bitcoin block using block-info.py script (also in my gist) and after that uses telegram-msg (also in my gist) to send that information to Telegram (Bitcoin-Notifier group)
#!/bin/bash
# Get information about the block
info=()
while IFS= read -r line; do
info+=( "$line" )
done < <( python3 /home/bitcoin/scripts/block-info.py "$1" )
# Notify the information
telegram-msg Bitcoin-Notifier "|=== NEW BLOCK ===|" "${info[@]}"
@davidlj95
davidlj95 / [email protected]
Last active March 20, 2018 22:08
bitcoind Systemd Unit service (with templates)
[Unit]
Description=Bitcoin's [%i] distributed currency daemon
After=network.target
[Service]
User=bitcoin-%i
Group=bitcoin-%i
Type=forking
PIDFile=/var/blockchain/bitcoin/bitcoind_%i.pid
@davidlj95
davidlj95 / bitcoin-cli wrapper
Created April 8, 2018 18:27
Extends the functionality of the bitcoin-cli tool allowing to select multiple configurations with the first parameter and other extra cool funcs
#!/bin/bash
# Description: Allows to switch between RPC
# client configurations inside
# ~/.bitcoin folder. If no
# config found, takes default
# Usage:
# bitcoin-cli <node_config> [args]
#
# Passes ~/.bitcoin/<node_config>.conf as
# the configuration file to bitcoin-cli
@davidlj95
davidlj95 / pip-update.sh
Last active June 18, 2018 17:52
Updates all outdated Python packages using `pip`
#!/bin/bash
# Name: `pip` package updater
# Description: checks `pip` outdated packages and updates them all at once
# Source:
# https://stackoverflow.com/questions/2720014/upgrading-all-packages-with-pip
pip list --outdated --format=freeze | \
grep -v '^\-e' | \
cut -d = -f 1 | \
xargs -n1 pip install -U
@davidlj95
davidlj95 / class_registry.py
Last active August 27, 2018 13:39
Python 3: Class registry
"""Implements a class registry based on its name using Python 3 metaclasses
**Source:**
- https://effectivepython.com/2015/02/02/\
register-class-existence-with-metaclasses/
"""
REGISTRY = {}
"""