Skip to content

Instantly share code, notes, and snippets.

@yous
yous / replace-fonts-macos.user.css
Last active Sep 16, 2021
Replace old fonts with new ones
View replace-fonts-macos.user.css
/* ==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 Nov 22, 2018
Custom CSS for Korean fonts on Safari
View safari-fonts.css
@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 Oct 2, 2018
256 colors for Open Color according to CIEDE2000
View color.py
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 Dec 15, 2017 — forked from chrismdp/http
Simple http server in ruby, that ensures there's no browser caching. For serving static files in development.
View server
#!/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 Dec 5, 2016
Thin + Rack file server with basic auth on Windows
View server.rb
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 Dec 5, 2016
Multithreaded SimpleHTTPServer with basic auth
View server.py
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 Dec 5, 2016
Simple multithreaded Flask file server with basic auth
View server.py
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 Jan 5, 2016
Print 256 colors
View colors.sh
#!/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 Dec 31, 2015
Happy New Year
View new_year.rb
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
View maze.rb
def print_maze(width, height, hori_walls, vert_walls)
puts ' ' + '-' * (width * 2 - 1)
(height - 1).times do |y|
print '|'
(width - 1).times do |x|
print ' '
print hori_walls[y][x] ? '|' : ' '
end
puts ' |'