Skip to content

Instantly share code, notes, and snippets.

@lackofdream
lackofdream / Nelson-Drops.html
Last active August 30, 2021 10:59
Nelson Drops.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Nelson Drops</title>
<script src="https://unpkg.com/react@17/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>
<!-- Don't use this in production: -->
#!/bin/bash
function _pre_read_input {
apt-get update
apt-get install -y pwgen
}
function read_input {
_pre_read_input
read -p "shadowsocks config dir[/etc/shadowsocks-libev]: " SS_CONFIG_DIR
@lackofdream
lackofdream / main.py
Last active August 8, 2016 08:21
scores with prettytable
#!/usr/bin/python3
import requests
from bs4 import BeautifulSoup
from prettytable import PrettyTable
import sys
from urllib.parse import urlencode
import getpass
class Score:
@lackofdream
lackofdream / backup.sh
Created May 24, 2016 09:03
a backup script
#!/bin/bash
rsync -aAXv --delete-before --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/var/*","*/Downloads/*","/srv/deluge/*"} / $TARGET
@lackofdream
lackofdream / uptweet.py
Last active April 11, 2016 18:55
UpTweet
import subprocess
import tweepy
import os
import socket
a = subprocess.Popen('uptime', stdout=subprocess.PIPE)
s = a.communicate()
res = s[0].decode('utf-8')
hostname = socket.gethostname()
@lackofdream
lackofdream / c.hs
Created March 21, 2016 11:20
Algorithm Ex1-3
module Main where
data Tree a = Node a [Tree a]
data BinTree a = Empty | Branch {
value :: a,
leftChild :: BinTree a,
rightChild :: BinTree a
}
#!/usr/bin/perl -w
use strict;
my $TempCompFileName = shift(@ARGV);
my $OutFileName = shift(@ARGV);
my ($start_addr, $appd_cks, $appd_len) = (0);
sub appendCks
@lackofdream
lackofdream / gen_ignore_list.sh
Created March 5, 2016 22:00
gen_ignore_list
wget -O- 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' | awk -F\| '/CN\|ipv4/ { printf("%s/%d\n", $4, 32-log($5)/log(2)) }' > /etc/shadowsocks/ignore.list
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
const int N = 10005;
vector<pair<int, long long> > a[N];
map<int, long long> dp[N];
@lackofdream
lackofdream / gen_ics.py
Last active February 24, 2016 06:11
\xd1\xa7\xc9\xfa\xb8\xf6\xc8\xcb\xd0\xc5\xcf\xa2\xcf\xb5\xcd\xb3
from bs4 import BeautifulSoup
from datetime import datetime, timedelta
import re
def get_start_day():
return datetime(2016, 2, 29)
def date_to_str(dt):