Skip to content

Instantly share code, notes, and snippets.

View vayn's full-sized avatar

Vayne Tsai vayn

View GitHub Profile
@Phate6660
Phate6660 / lobsters-dark.css
Last active January 16, 2022 08:42
A dark userstyle for https://lobste.rs that aims to be simple and robust.
body, textarea, input, button {
font-size: 11px;
}
a {
color: green;
}
p>a {
color: green !important;
@masdude
masdude / readme.txt
Last active May 5, 2023 12:13
小容量MBP外接固态硬盘扩容解决方案
针对小容量mac book扩容的解决方案
需要购买:
1.nvme硬盘盒
2.大容量 nvme固态硬盘(推荐500G以上容量)
推荐下面这种侧插式nvme硬盘盒,完美匹配mac book,速度是10Gb/s,而且关机也不用取下。
缺点是要占用一边两个雷电接口,硬盘盒自带一个充电接口,
算下来其实还好,不充电的情况下,多占了一个雷电接口。
@abc1763613206
abc1763613206 / bvtest.py
Last active February 23, 2024 22:18
BVID Validate
import requests
import json
import random
Back_URL = 'https://api.bilibili.com/x/web-interface/archive/stat?aid='
headers = {
'Cookie': "Replace Me With REAL COOKIE" ,
'Pragma': 'no-cache',
@edmundsmith
edmundsmith / writeup.md
Created July 7, 2019 20:47
Method for Emulating Higher-Kinded Types in Rust

Method for Emulating Higher-Kinded Types in Rust

Intro

I've been fiddling about with an idea lately, looking at how higher-kinded types can be represented in such a way that we can reason with them in Rust here and now, without having to wait a couple years for what would be a significant change to the language and compiler.

There have been multiple discussions on introducing higher-ranked polymorphism into Rust, using Haskell-style Higher-Kinded Types (HKTs) or Scala-looking Generalised Associated Types (GATs). The benefit of higher-ranked polymorphism is to allow higher-level, richer abstractions and pattern expression than just the rank-1 polymorphism we have today.

As an example, currently we can express this type:

@justlaputa
justlaputa / unstar-all-repos.md
Last active April 12, 2024 16:01
How to unstar all your github starred repos
@duckythescientist
duckythescientist / tqdm_longrun.py
Created October 9, 2017 14:18
Tqdm wrapper and decorator to give a long-running function a progress bar
#/usr/bin/env python3
import time
import threading
import functools
import tqdm
def long_running_function(*args, **kwargs):

Where you able to produce a binary directly from the Rust build tools that you could submit to the app/play store?


Not quite, but I tried to get as close to that as was reasonably possible. Alas, things ended up a little convoluted.

For iOS, I have a nearly empty Xcode project with a build script that copies my cargo produced executable into the .app that Xcode generates (before Xcode signs it). The build script also uses lipo to merge the executables for each architecture I’m targeting (e.g. armv7 and aarch64 for non-simulator devices) into a single, universal binary.

On top of that, there are various iOS-y things that need to happen before my application’s main method is called. SDL2 provides the Objective-C code that does all of that. In a C or C++ game, SDL2 renames main to SDL_main, and then [inserts its own mai

@delneg
delneg / f.html
Created April 12, 2017 18:00
Django 'active' for navbar
# In this example I make difference for 3 urls, this can be messy if you have an URL that is like /posts/whatever/contacts because there is 2 places that will return True (2nd and 3rd li)
# So here is the better option for handling this:
{% with request.resolver_match.url_name as url_name %}
<ul id="menu">
<li class="{% if url_name == 'home' %}active{% endif %}">Home</li>
<li class="{% if url_name == 'blog' %}active{% endif %}">Posts</li>
<li class="{% if url_name == 'contact' %}active{% endif %}">Contact</li>
</ul>
@venj
venj / trans_gif.sh
Created November 1, 2016 03:59
convert video to gif
#!/bin/sh
# Convert video to gif.
if [[ $# -ne 3 ]]; then
echo "Usage: trans_gif source.mp4 target.gif 300"
exit 1
fi
palette="/tmp/palette.png"
filters="fps=15,scale=$3:-1:flags=lanczos"
@Alir3z4
Alir3z4 / utils.py
Created August 9, 2016 06:19
Create a hash of a file on upload time and save it for Django FileField/ImageField
def hash_file(file, block_size=65536):
hasher = hashlib.md5()
for buf in iter(partial(file.read, block_size), b''):
hasher.update(buf)
return hasher.hexdigest()
def upload_to(instance, filename):
"""