This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>simple websocket</title> | |
| </head> | |
| <body> | |
| simple websocket | |
| <script> | |
| document.addEventListener('DOMContentLoaded', function() { | |
| var ws = new WebSocket("ws://" + location.host + "/ws"); |
This file contains hidden or 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
| <!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) { |
This file contains hidden or 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
| <!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'); |
This file contains hidden or 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
| 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"]), |
This file contains hidden or 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
| #include <iostream> | |
| #include <omp.h> | |
| #include <thread> | |
| using namespace std; | |
| void sleep(int num) { | |
| std::this_thread::sleep_for(std::chrono::seconds(3)); | |
| } |
This file contains hidden or 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
| #include <iostream> | |
| using namespace std; | |
| template<typename Func> | |
| void call_f(Func f) { | |
| f(); | |
| } | |
| void hello () { |
This file contains hidden or 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
| #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) { |
This file contains hidden or 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
| #include <iostream> | |
| #include <dirent.h> | |
| int main(int argc, char* argv[]) { | |
| const char* directory; | |
| if (argc < 2) { | |
| directory = "."; | |
| } else { | |
| directory = argv[1]; | |
| } |
This file contains hidden or 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
| #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; |
This file contains hidden or 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
| fn main() { | |
| let mut xs = vec![]; | |
| for i in 1..100 { | |
| xs.push(i); | |
| } | |
| println!("Vector: {:?}", xs); | |
| } |