openssl genrsa 2048 > cert.key
openssl req -new -batch -key cert.key > cert.csr
openssl x509 -days 3650 -req -signkey cert.key < cert.csr > cert.crt # valid for a decade (3650 days)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c = (1 - (2 * l - 1).abs) * s | |
x = c * (1 - ((h / 60.0) % 2 - 1).abs) | |
m = l - c / 2 | |
rgb = [ | |
[c, x, 0], | |
[x, c, 0], | |
[0, c, x], | |
[0, x, c], | |
[x, 0, c], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git filter-branch -f --env-filter ' | |
if [ "$GIT_COMMITTER_EMAIL" != "yuki@creasty.com" ]; then | |
export GIT_AUTHOR_NAME="nondisclosure" | |
export GIT_AUTHOR_EMAIL="nondisclosure@creasty.com" | |
export GIT_COMMITTER_NAME="nondisclosure" | |
export GIT_COMMITTER_EMAIL="nondisclosure@creasty.com" | |
fi | |
' --tag-name-filter cat -- --branches --tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Base32 | |
ENCODE_MAP = '0123456789ABCDEFGHJKMNPQRSTVWXYZ' | |
DECODE_MAP = Hash[ | |
ENCODE_MAP | |
.each_char | |
.zip(0..31) | |
.concat([ | |
['I', 1], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Concerns | |
module SuppressStatus | |
extend ActiveSupport::Concern | |
included do | |
protected :suppress_status! | |
protected :suppress_status? | |
prepend_after_action :suppress_status! |
- Algorithm for computing a score for move and time based game [closed]
http://stackoverflow.com/questions/14679822/algorithm-for-computing-a-score-for-move-and-time-based-game - How Reddit ranking algorithms work
http://amix.dk/blog/post/19588 - How Hacker News ranking algorithm works
http://amix.dk/blog/post/19574
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
weightedRandom = (spec) -> | |
len = spec.length | |
totalWeight = 0 | |
totalWeight += (spec[i] ?= (1 / len)) for i in [0...len] by 1 | |
rand = Math.random() * totalWeight | |
weightSum = 0 | |
for i in [0...len] by 1 | |
weightSum += spec[i] | |
return i if rand <= weightSum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select @@global.time_zone, now(), convert_tz(now(), 'utc', '+09:00'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rmagick' | |
class ColorExtraction | |
DEFAULT_QUANTIZER = 150 | |
def self.from_file(file, quantize: DEFAULT_QUANTIZER) | |
new(Magick::ImageList.new(file), quantize: quantize) | |
end |
NewerOlder