Skip to content

Instantly share code, notes, and snippets.

View TimothyYe's full-sized avatar
🖋️
Creating bugs...

Timothy TimothyYe

🖋️
Creating bugs...
  • Singapore
View GitHub Profile
@TimothyYe
TimothyYe / example.py
Created July 25, 2024 13:52
Stacking to Improve Model Performance
import numpy as np
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
from xgboost import XGBClassifier
# Generate a sample dataset
X, y = make_classification(n_samples=1000, n_features=20, n_classes=2, random_state=42)
@TimothyYe
TimothyYe / cleanup.sh
Created March 20, 2019 14:42 — forked from superseb/cleanup.sh
Cleanup host added as custom to Rancher 2.0
#!/bin/sh
docker rm -f $(docker ps -qa)
docker volume rm $(docker volume ls -q)
cleanupdirs="/var/lib/etcd /etc/kubernetes /etc/cni /opt/cni /var/lib/cni /var/run/calico /opt/rke"
for dir in $cleanupdirs; do
echo "Removing $dir"
rm -rf $dir
done
@TimothyYe
TimothyYe / cert.sh
Last active March 24, 2022 11:02
Create LetsEncrypt cert with docker
#!/bin/bash
docker run -it --rm --name certbot \
-v "/etc/letsencrypt:/etc/letsencrypt" \
-v "/var/lib/letsencrypt:/var/lib/letsencrypt" \
-v "/data/letsencrypt:/.secrets" \
-p 80:80 \
-p 443:443 \
certbot/dns-cloudflare certonly \
-d $1
@TimothyYe
TimothyYe / GoConcurrency.md
Created March 7, 2019 16:00 — forked from rushilgupta/GoConcurrency.md
Concurrency in golang and a mini Load-balancer

INTRO

Concurrency is a domain I have wanted to explore for a long time because the locks and the race conditions have always intimidated me. I recall somebody suggesting concurrency patterns in golang because they said "you share the data and not the variables".

Amused by that, I searched for "concurrency in golang" and bumped into this awesome slide by Rob Pike: https://talks.golang.org/2012/waza.slide#1 which does a great job of explaining channels, concurrency patterns and a mini-architecture of load-balancer (also explains the above one-liner).

Let's dig in:

Goroutines

@TimothyYe
TimothyYe / send-sms.go
Created October 18, 2018 08:29 — forked from ivajloip/send-sms.go
Sending an SMS Text Message using AWS SNS service in GoLang
//assumes you have the following environment variables setup for AWS session creation
// AWS_SDK_LOAD_CONFIG=1
// AWS_ACCESS_KEY_ID=XXXXXXXXXX
// AWS_SECRET_ACCESS_KEY=XXXXXXXX
// AWS_DEFAULT_REGION=us-east-1
package main
import (
"fmt"
@TimothyYe
TimothyYe / 知乎日报API.md
Created December 27, 2017 08:27 — forked from v5tech/知乎日报API.md
知乎日报API
@TimothyYe
TimothyYe / main.go
Created November 5, 2017 14:17
Pumpcloud monitor program
package main
import (
"fmt"
"log"
"os"
"strings"
"github.com/PuerkitoBio/goquery"
"github.com/parnurzeal/gorequest"
@TimothyYe
TimothyYe / main.go
Created October 30, 2017 15:07
download MM
package main
import (
"io"
"os"
"fmt"
"sync"
"strconv"
"strings"
@TimothyYe
TimothyYe / bench.sh
Created October 24, 2017 01:52
Bench test script
#!/usr/bin/env bash
#
# Description: Auto test download & I/O speed script
#
# Copyright (C) 2015 - 2016 Teddysun <[email protected]>
#
# Thanks: LookBack <[email protected]>
#
# URL: https://teddysun.com/444.html
#
@TimothyYe
TimothyYe / main.go
Created September 30, 2017 08:23 — forked from walm/main.go
Simple Golang DNS Server
package main
import (
"fmt"
"log"
"strconv"
"github.com/miekg/dns"
)