Skip to content

Instantly share code, notes, and snippets.

brew install emacs --with-cocoa --japanese
ln -s /usr/local/Cellar/emacs-mac/emacs-25.1-z-mac-6.1/Emacs.app /Applications/
fn main() {
let mut xs = vec![];
for i in 1..100 {
xs.push(i);
}
println!("Vector: {:?}", xs);
}
@sat0b
sat0b / reverse.cpp
Created June 14, 2017 11:09
日本語を逆順に表示
#include <string>
#include <codecvt>
#include <iostream>
using namespace std;
int main() {
wstring_convert<codecvt_utf8<char32_t>, char32_t> cv;
u32string s = U"あいうえお";
for (auto v : s)
cout << cv.to_bytes(v) << endl;
#include <iostream>
#include <dirent.h>
int main(int argc, char* argv[]) {
const char* directory;
if (argc < 2) {
directory = ".";
} else {
directory = argv[1];
}
#include <iostream>
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
int main() {
const fs::path path("dir");
boost::system::error_code error;
const bool result = fs::create_directory(path, error);
if (!result || error) {
#include <iostream>
using namespace std;
template<typename Func>
void call_f(Func f) {
f();
}
void hello () {
#include <iostream>
#include <omp.h>
#include <thread>
using namespace std;
void sleep(int num) {
std::this_thread::sleep_for(std::chrono::seconds(3));
}
import yaml
import twitter
def get_tweet():
with open("config.yaml") as f:
config = yaml.load(f)
stream = twitter.TwitterStream(auth=twitter.OAuth(
config["access_token"], config["access_token_secret"],
config["consumer_key"], config["consumer_secret_key"]),
@sat0b
sat0b / index.html
Created June 3, 2017 18:14
one line chat
<!DOCTYPE html>
<html>
<head>
<title>One line chat</title>
</head>
<body>
<script>
document.addEventListener('DOMContentLoaded', function() {
var ws = new WebSocket("ws://" + location.host + "/ws");
var msg = document.getElementById('msg');
@sat0b
sat0b / index.html
Created June 3, 2017 11:16
digital clock based on websocket
<!DOCTYPE html>
<html>
<head>
<title>Digital clock</title>
</head>
<body>
<script>
document.addEventListener('DOMContentLoaded', function() {
var ws = new WebSocket("ws://" + location.host + "/ws");
ws.onopen = function(event) {