Skip to content

Instantly share code, notes, and snippets.

View kahlys's full-sized avatar
🙀
screaming

kahlys kahlys

🙀
screaming
View GitHub Profile
@kahlys
kahlys / dial-pq-via-ssh.go
Last active January 31, 2023 16:16 — forked from vinzenz/dial-pq-via-ssh.go
Use postgres via SSH in Golang
package main
import (
"database/sql"
"database/sql/driver"
"flag"
"fmt"
"net"
"os"
"time"
@kahlys
kahlys / ttygame.rs
Created March 1, 2020 01:24
an unsafe tty game template in rust using termion
extern crate termion;
use std::fmt;
use std::io::{stdin, stdout, Write};
use termion::clear;
use termion::color;
use termion::cursor;
use termion::event::Key;
use termion::input::TermRead;
use termion::raw::IntoRawMode;
@kahlys
kahlys / secret_santa_genetic.py
Last active February 5, 2020 11:18
An overkill solution for TSP applied to secret santa
import random
class Node:
def __init__(self, id):
self.id = id
self.next = {}
def __str__(self):
return "{}".format(self.id)
$ docker ps --format "table {{.ID}}\t{{.Image}}\t{{.Status}}\t{{.Names}}\t{{.Ports}}"
func formatRequest(r *http.Request) string {
// Create return string
var request []string
// Add the request string
url := fmt.Sprintf("%v %v %v", r.Method, r.URL, r.Proto)
request = append(request, url)
// Add the host
request = append(request, fmt.Sprintf("Host: %v", r.Host))
// Loop through headers
for name, headers := range r.Header {
@kahlys
kahlys / ast.go
Last active February 11, 2019 11:55
golang ast parsing variables values (https://play.golang.org/p/zraHZHDEGok)
package main
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
"strings"
)
package main
import (
"io"
"log"
"net"
"net/http"
"time"
"github.com/prometheus/client_golang/prometheus"
@kahlys
kahlys / aes.c
Created June 14, 2017 10:02
mbedtls examples
void aes() {
mbedtls_cipher_context_t ctx;
mbedtls_cipher_context_t ctx2;
unsigned char error[1024];
unsigned char key[32] = {
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import urllib2
import re
import unicodedata
class bcolors:
HEADER = '\033[95m'