Skip to content

Instantly share code, notes, and snippets.

@Hexa
Hexa / rsa.cr
Last active October 28, 2016 16:35
rsa
require "openssl"
#@[Link("crypto")]
lib LibCrypto
alias RSA = Void*
alias BIGNUM = Void*
RSA_3 = 0x3
RSA_F4 = 0x10001
@Hexa
Hexa / nginx.service
Created September 7, 2016 14:57
/etc/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target auditd.service
[Service]
ExecStart=/home/ubuntu/nginx/sbin/nginx -p /home/ubuntu/nginx
ExecReload=/home/ubuntu/nginx/sbin/nginx -p /home/ubuntu/nginx -s reload
ExecStop=/home/ubuntu/nginx/sbin/nginx -p /home/ubuntu/nginx -s stop
Restart=always
Type=simple
@Hexa
Hexa / relay.html
Last active August 10, 2016 12:58
<html>
<head>
<title>relay</title>
</head>
<body>
<div id="remote">
</div>
<hr />
<input type="Button" id="add" value="add"></input>
<div id="children">
@Hexa
Hexa / channel.cr
Last active April 26, 2016 15:49
channel
j = 0
SIZE = 10000
a = Deque(Int32).new(SIZE)
#a = [] of Int32
in_channel = Channel(String).new
out_channel = Channel(String).new
spawn do
loop do
@Hexa
Hexa / donwload.js
Created April 22, 2016 15:35
XHR でダウンロード
var filename = "example.webm";
var xhr = new XMLHttpRequest();
xhr.responseType = "arraybuffer";
xhr.open("GET", "/" + filename);
xhr.onreadystatechange = function () {
if ((this.readyState === 4) && (this.status === 200)) {
var blob = new Blob([this.response], {
type: "video/webm"
});
var video = document.getElementById("video");
@Hexa
Hexa / address.html
Created April 9, 2016 12:24
JS でローカルのアドレスを取得
<html>
<head>
<title>IP Address</title>
</head>
<body>
<div>
<h3>IP Address</h3>
<ul id="list"></ul>
</div>
<script>
$ nghttp -v https://localhost:443/
[ 0.001] Connected
The negotiated protocol: h2
[ 0.003] recv SETTINGS frame <length=18, flags=0x00, stream_id=0>
(niv=3)
[SETTINGS_MAX_CONCURRENT_STREAMS(0x03):128]
[SETTINGS_INITIAL_WINDOW_SIZE(0x04):2147483647]
[SETTINGS_MAX_FRAME_SIZE(0x05):16777215]
[ 0.003] recv WINDOW_UPDATE frame <length=4, flags=0x00, stream_id=0>
(window_size_increment=2147418112)
@Hexa
Hexa / gist:a8d848ba3e610c90e9b9
Last active August 29, 2015 14:24
クロスルート
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'openssl'
# ルート
old_root_ca_private_key = OpenSSL::PKey::RSA.new(2048)
old_root_ca_cert = OpenSSL::X509::Certificate.new
old_root_ca_cert.version = 2
issuer = subject = OpenSSL::X509::Name.new
$ openssl x509 -noout -text -in \*.c.ssl.fastly.net
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
07:64:70:26:7c:93:08:58:75:31:10:8f:32:a4:4f:45
Signature Algorithm: sha256WithRSAEncryption
Issuer: C=US, O=DigiCert Inc, OU=www.digicert.com, CN=DigiCert SHA2 High Assurance Server CA
Validity
Not Before: Mar 13 00:00:00 2014 GMT
$ openssl x509 -noout -text -in a.ssl.fastly.net
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
01:e8:7d:87:da:d5:21:f0:05:72:28:ee:85:7a:0a:e6
Signature Algorithm: sha256WithRSAEncryption
Issuer: C=US, O=DigiCert Inc, OU=www.digicert.com, CN=DigiCert SHA2 High Assurance Server CA
Validity
Not Before: Dec 8 00:00:00 2014 GMT