Skip to content

Instantly share code, notes, and snippets.

View mattgathu's full-sized avatar
👾
👾 👾 👾

Matt Gathu mattgathu

👾
👾 👾 👾
View GitHub Profile

Effective Engineer - Notes

What's an Effective Engineer?

  • They are the people who get things done. Effective Engineers produce results.

Adopt the Right Mindsets

@mattgathu
mattgathu / main.rs
Last active August 14, 2023 19:22
Simple Event Hooks in Rust, Observer pattern in Rust
use std::io;
use std::str;
use std::error::Error;
use std::io::{Read, Write};
use std::net::TcpStream;
#[allow(unused_variables)]
pub trait Events {
fn on_connect(&self, host: &str, port: i32) {}
fn on_error(&self, err: &str) {}
@mattgathu
mattgathu / DI.m3u
Created July 14, 2017 06:31 — forked from sim642/DI.m3u
Digitally Imported premium streams
#EXTM3U
#EXTINF:-1,Digitally Imported - Ambient
http://pub1.diforfree.org:8000/di_ambient_hi
#EXTINF:-1,Digitally Imported - Big Room House
http://pub1.diforfree.org:8000/di_bigroomhouse_hi
#EXTINF:-1,Digitally Imported - Breaks
http://pub1.diforfree.org:8000/di_breaks_hi
@mattgathu
mattgathu / higuita_dump.py
Created September 17, 2016 07:00 — forked from ryukinix/higuita_dump.py
Script to download all academic content about lectures at www.higuita.com.br of Prof. Alexandre F. Beletti at UFPA
#!/usr/bin/env python
# coding=utf-8
#
# Python Script
#
# Copyleft © Manoel Vilela
#
#
# stdlib
@mattgathu
mattgathu / levenshtein.py
Last active May 12, 2016 07:42
Levenshtein distance between a and b
def levenshtein(a,b):
"Calculates the Levenshtein distance between a and b."
n, m = len(a), len(b)
if n > m:
# Make sure n <= m, to use O(min(n,m)) space
a,b = b,a
n,m = m,n
current = range(n+1)
for i in range(1,m+1):
@mattgathu
mattgathu / genlogfiles.py
Created July 22, 2015 06:27
Python logs file names and contents generators
def gen_log_files():
"""Generate log files names"""
for root, _, files in os.walk(DEFAULT_LOG_DIR):
for name in files:
if is_pref_file(name):
yield os.path.join(root, name)
def gen_contents(fnames):
"""Generate file contents
"""
@mattgathu
mattgathu / cliparser.py
Created July 22, 2015 06:09
Python Command Line Arguments Parser
DESCRIPTION = """logfind is a simple commandline tool that allows log files
scanning without having to explicitly declare every file on the command line."""
EPILOG = 'Created by insert-your-name'
def cli_parser():
"""Command Line Arguments parser
"""
parser = argparse.ArgumentParser(description=DESCRIPTION, epilog=EPILOG)
parser.add_argument('term', nargs='+', metavar='SEARCH_TERM', help='search term(s)')
// These two need to be declared outside the try/catch
// so that they can be closed in the finally block.
HttpURLConnection urlConnection = null;
BufferedReader reader = null;
// Will contain the raw JSON response as a string.
String forecastJsonStr = null;
try {
// Construct the URL for the OpenWeatherMap query