Skip to content

Instantly share code, notes, and snippets.

@ymmt2005
ymmt2005 / ipv6_linklocal.cpp
Created August 12, 2014 08:52
IPv6 link local address resolution
#include <arpa/inet.h>
#include <ifaddrs.h>
#include <iostream>
#include <netdb.h>
#include <sys/socket.h>
#include <sys/types.h>
int main() {
struct ifaddrs* addr;
getifaddrs(&addr);
#!/usr/bin/env jjs
/*####################################################################################################################################
# As Nashorn does not have http capabilities through XMLHttpRequest (DOM API), we have to use regular Java classes instead.
# This sample shows how this can be acheived without depending on any third party libraries. Just a standard Java 8 JDK.
# Make sure to have JAVA_HOME/bin on your PATH for the shebang to work. Then just chmod +x away and run...
# Alternatively if you're on a non *nix OS, start with jjs -scritping httpsample.js
####################################################################################################################################*/
var url = "https://api.github.com/users/billybong/repos";
var response;
@matsuu
matsuu / nginx.conf
Last active August 29, 2015 14:25
時間帯によってupstreamを変える
map $time_iso8601 $upstream {
default "app-b.example.net";
"~T(0|1[01])" "app-a.example.net";
}
server {
listen 80;
server_name _;
location / {
map $time_iso8601 $upstream {
default "app-b.example.org";
"~T(0|1[01])" "app-a.example.org";
}
server {
server_name app.example.org;
location / {
proxy_pass http://127.0.0.1;
proxy_set_header Host $upstream;
@qnighy
qnighy / rust-patterns.md
Last active March 6, 2025 19:03
Rustのパターンっぽいやつメモ

パターンとはその言語が抽象化できなかった敗北の歴史である。 しかしどんなに優れた言語であってもあらゆる繰り返しに勝てるわけではない。 人は必ずメタ繰り返しを欲するからだ。 そしてそれはRustも例外ではない。

ここでは、OOPでも知られているパターンよりも、Rustに特有のパターンを思いつく限りまとめてみた。名前は適当。

  • crate splitting
    • でかいcrateを分割して、見通しを良くする・再コンパイルの分量を削減する・並列コンパイルを可能にする
  • 親玉crate(全てにdependする)と殿crate(全てにdependされる)があることが多いので、だいたい束みたいな形になる。