Skip to content

Instantly share code, notes, and snippets.

View literadix's full-sized avatar
💭
I may be slow to respond.

literadix

💭
I may be slow to respond.
View GitHub Profile
import pandas as pd
import numpy as np
from sklearn.preprocessing import OneHotEncoder
# https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.OneHotEncoder.html#sklearn.preprocessing.OneHotEncoder
# https://datascienceparichay.com/article/numpy-hstack/
if __name__ == '__main__':
array = [['Male', 1, 'Green', 12, 5],
@literadix
literadix / main.rs
Created September 29, 2021 05:45
RUST: Write and read to files from threads, channel communication
--- Cargo.toml ---
[package]
name = "actix-example"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
# https://www.kdnuggets.com/2017/03/simple-xgboost-tutorial-iris-dataset.html
# https://joblib.readthedocs.io/en/latest/
import pandas as pd
import numpy as np
import xgboost as xgb
import numpy as np
from sklearn import datasets
from sklearn.model_selection import train_test_split
import joblib
@literadix
literadix / golang_write_to_gzip_file.go
Created July 9, 2019 10:49
golang write to gzip file
/*
This is an example of a golang gzip writer program,
which appends data to a file.
*/
package main
package main
import "fmt"
// https://www.coursera.org/learn/golang-functions-methods/peer/UxoIW/module-1-activity-bubble-sort-program/submit
// https://tutorialedge.net/golang/implementing-bubble-sort-with-golang/
func BubbleSort(input []int) {
n := len(input)
@literadix
literadix / json.go
Created May 22, 2019 13:43 — forked from uudashr/json.go
Custom JSON time.Time format
const jsonTimeLayout = "2006-01-02T15:04:05+07:00"
// JSONTime is the time.Time with JSON marshal and unmarshal capability
type JSONTime struct {
time.Time
}
// UnmarshalJSON will unmarshal using 2006-01-02T15:04:05+07:00 layout
func (t *JSONTime) UnmarshalJSON(b []byte) error {
parsed, err := time.Parse(jsonTimeLayout, string(b))
@literadix
literadix / ical.md
Created February 20, 2019 15:58 — forked from meskarune/ical.md
parsing ical file with python icalendar

Archwomen.ics file

BEGIN:VCALENDAR
PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
VERSION:2.0
BEGIN:VEVENT
CREATED:20170220T182458Z
LAST-MODIFIED:20170220T182458Z
DTSTAMP:20170220T182458Z
@literadix
literadix / README-python-service-on-systemd-activated-socket.md
Created January 24, 2019 15:13 — forked from kylemanna/README-python-service-on-systemd-activated-socket.md
An example network service with systemd-activated socket in Python. #systemd #python #socket #socket-activation

README

The example below creates a TCP server listening on a stream (i.e. SOCK_STREAM) socket. A similar approach can be followed to create a UDP server on a datagram (i.e. SOCK_DGRAM) socket. See man systemd.socket for details.

An example server

Create an simple echo server at ~/tmp/foo/serve.py.

input {
gelf {}
}
filter {
if [message] {
grok {
match => { "message" => "%{IPORHOST:remote_ip} - %{DATA:user_name} \[%{HTTPDATE:access_time}\] \"%{WORD:http_method} %{DATA:url} HTTP/%{NUMBER:http_version}\" %{NUMBER:response_code} %{NUMBER:body_sent_bytes} \"%{DATA:referrer}\" \"%{DATA:agent}\"" }
}
if "_grokparsefailure" in [tags] {
}
@literadix
literadix / install-redis.md
Created September 6, 2018 10:59 — forked from hackedunit/install-redis.md
Install and configure Redis on Ubuntu 16.04 with systemd
  1. Install pre-requisities

sudo apt-get install build-essential tcl

  1. Install Redis
cd /tmp
curl -O http://download.redis.io/redis-stable.tar.gz
tar xzvf redis-stable.tar.gz