Skip to content

Instantly share code, notes, and snippets.

View hashlash's full-sized avatar

hashlash

View GitHub Profile
from sklearn.naive_bayes import _BaseNB
class MultiNB(_BaseNB):
def __init__(self, models_dict):
self.models_dict = models_dict
def fit(self, X, y, **kwargs):
for column, model in self.models_dict.items():
model.fit(X[:, column], y, **kwargs)
c := make(chan Return)
ch.NotifyReturn(c)
for r := range(c) {
fmt.Println(r)
}
🔥 Creating kvm2 VM (CPUs=2, Memory=2200MB, Disk=20000MB) ...
I0324 14:25:28.958816 22940 main.go:110] libmachine: Found binary path at /home/hashlash/.minikube/bin/docker-machine-driver-kvm2
I0324 14:25:28.958860 22940 main.go:110] libmachine: Launching plugin server for driver kvm2
I0324 14:25:28.969823 22940 main.go:110] libmachine: Plugin server listening at address 127.0.0.1:44705
I0324 14:25:29.028042 22940 main.go:110] libmachine: () Calling .GetVersion
I0324 14:25:29.029004 22940 main.go:110] libmachine: Using API Version 1
I0324 14:25:29.029044 22940 main.go:110] libmachine: () Calling .SetConfigRaw
I0324 14:25:29.029644 22940 main.go:110] libmachine: () Calling .GetMachineName
I0324 14:25:29.030153 22940 main.go:110] libmachine: (kvm) Calling .GetMachineName
I0324 14:25:29.030396 22940 main.go:110] libmachine: (kvm) Calling .DriverName
@hashlash
hashlash / gsoc-django-secret-manager.md
Last active August 31, 2021 04:50
Django GSOC 2020 Proposal: Secrets Manager
@hashlash
hashlash / gist:e6620513b541a3a8c441272c39918bfe
Created April 11, 2020 09:41
Run command with unlimited sudo session time
#!/bin/sh
(while true; do sudo -v; sleep 60; done)&
job_pid=$!
echo $job_pid
cleanup(){
kill $job_pid
}
@hashlash
hashlash / battleships.py
Last active April 27, 2020 16:02
Battleship puzzle solver
from itertools import combinations, product
from pysat.solvers import Minisat22
from sympy.core.symbol import Symbol
from sympy.logic.boolalg import And, Equivalent, Not, Or, to_cnf
def simplify_op(op, args):
simplified = op(*args)
if isinstance(simplified, op):
@hashlash
hashlash / README.md
Last active May 29, 2020 08:19
A Tour of Go Exercise: rot13Reader https://tour.golang.org/methods/23

Some simple points that I think this code looks great:

  • Doesn't need any additional function(s)

  • Concise if case error handling, instead of:

    ...
    if err != nil {

return nil, err

@hashlash
hashlash / README.md
Created June 7, 2020 16:44
Logic Programming

Logic Programming

The Problem of Normal Logic Program

It use negation (unlike definite logic program) which make the logical entailment not hold.

  • Program Completion (Clark, 1978): change rule's implication to bi-implication

  • Stable Model Semantic (Gelfond and Lifschitz, 1988): remove negative literals (either the whole rule, or just the literal in the body)

@hashlash
hashlash / README.md
Last active December 6, 2024 17:19
Binary Exploitation Cheatsheet
@hashlash
hashlash / network.md
Last active June 25, 2020 14:36
Network Inspection Cheatsheet

ip

ip a
ip link show
ip r

lspci