Skip to content

Instantly share code, notes, and snippets.

@yous
yous / marked-google-drive.user.js
Last active October 12, 2023 02:43
Marked on Google Drive
// ==UserScript==
// @name Marked on Google Drive
// @namespace https://github.com/yous
// @version 1.1.0
// @description Render markdown preview on Google Drive
// @author yous
// @homepageURL https://gist.github.com/yous/0b48b98352215ab22eb8591b78f39361
// @updateURL https://gist.github.com/yous/0b48b98352215ab22eb8591b78f39361/raw/marked-google-drive.user.js
// @downloadURL https://gist.github.com/yous/0b48b98352215ab22eb8591b78f39361/raw/marked-google-drive.user.js
// @license MIT
@yous
yous / replace-fonts-macos.user.css
Last active September 16, 2021 11:57
Replace old fonts with new ones
/* ==UserStyle==
@name Replace fonts in macOS
@namespace https://github.com/yous
@version 1.0.0
@description Replace old fonts with better ones
@author yous
@homepageURL https://gist.github.com/yous/91ff6ca317304654aa71e7fdf504e25d
@updateURL https://gist.github.com/yous/91ff6ca317304654aa71e7fdf504e25d/raw/replace-fonts-macos.user.css
@license CC-BY-4.0
==/UserStyle== */
@yous
yous / safari-fonts.css
Created November 22, 2018 15:53
Custom CSS for Korean fonts on Safari
@font-face {
font-style: normal;
font-family: "Batang";
src: local("AppleMyungjo");
}
@font-face {
font-style: normal;
font-family: "바탕";
src: local("AppleMyungjo");
}
@yous
yous / color.py
Created October 2, 2018 11:29
256 colors for Open Color according to CIEDE2000
from colormath.color_objects import sRGBColor, LabColor
from colormath.color_conversions import convert_color
from colormath.color_diff import delta_e_cie2000
def hex_to_rgb(h):
return sRGBColor(h / 0x10000, (h / 0x100) % 0x100, h % 0x100,
is_upscaled=True)
@yous
yous / server
Last active December 15, 2017 04:54 — forked from chrismdp/http
Simple http server in ruby, that ensures there's no browser caching. For serving static files in development.
#!/usr/bin/env ruby
require 'webrick'
require 'optparse'
class NonCachingFileHandler < WEBrick::HTTPServlet::FileHandler
def prevent_caching(res)
res['ETag'] = nil
res['Last-Modified'] = Time.now + 100**4
res['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0'
res['Pragma'] = 'no-cache'
@yous
yous / server.rb
Created December 5, 2016 10:55
Thin + Rack file server with basic auth on Windows
require 'rack'
require 'thin'
dirname = File.expand_path(File.dirname(__FILE__))
fileroot = File.join(dirname, 'files')
module Rack
class UTF8Directory < Directory
class DirectoryBody < Directory::DirectoryBody
private
@yous
yous / server.py
Created December 5, 2016 10:49
Multithreaded SimpleHTTPServer with basic auth
import os
import base64
import SocketServer
import BaseHTTPServer
import SimpleHTTPServer
class AuthHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
''' Main class to present webpages and authentication. '''
def do_AUTHHEAD(self):
self.send_response(401)
@yous
yous / server.py
Created December 5, 2016 10:46
Simple multithreaded Flask file server with basic auth
import os.path
from functools import wraps
from flask import Flask, request, Response, redirect
from flask_autoindex import AutoIndex
fileroot = os.path.join(os.path.realpath(os.path.curdir), 'files')
app = Flask(__name__)
idx = AutoIndex(app,
browse_root=fileroot,
add_url_rules=False)
@yous
yous / colors.sh
Created January 5, 2016 10:44
Print 256 colors
#!/usr/bin/env bash
for i in {0..7}; do
next=$((${i} + 8))
printf "\x1b[38;5;${i}mcolour${i} \x1b[38;5;${next}mcolour${next}\n"
done
for i in {16..255}; do
printf "\x1b[38;5;${i}mcolour${i} "
if [[ $((${i} % 6)) == 3 ]]; then
printf "\n"
fi
@yous
yous / new_year.rb
Last active December 31, 2015 16:02
Happy New Year
class Happy
def initialize
print "#{self.class} New "
@year = Time.new.year
end
def method_missing(meth)
puts "#{__method__.to_s[/\w+/].capitalize} #{@year}#{meth.to_s[/\W+/]}"
end
end