Skip to content

Instantly share code, notes, and snippets.

@syohex
syohex / Screenshot_20210928-100031.png
Last active September 28, 2021 01:09
feedback to LingoChampApp
Screenshot_20210928-100031.png
@syohex
syohex / update-gh.sh
Created July 22, 2021 01:27
update gh script on Linux environment
#!/usr/bin/env bash
set -e
set -x
VERSION=$1
if [[ $VERSION == "" ]]; then
echo "Usage: update-gh version"
exit 1
fi
@syohex
syohex / sample.md
Last active December 6, 2020 02:26
test for code block with list
  1. #!/usr/bin/env ruby
    print "hello world"
  2. This is normal text
@syohex
syohex / main.go
Created November 11, 2020 16:34
Check Windows binary architecture in Golang
package main
import (
"debug/pe"
"fmt"
"os"
)
func main() {
if len(os.Args) < 2 {
@syohex
syohex / md5.cpp
Created September 12, 2020 16:25
g++ -std=c++17 md5.cpp -lcryptopp
#include <crypto++/files.h>
#include <crypto++/hex.h>
#include <crypto++/md5.h>
#include <filesystem>
#include <string>
namespace {
std::string md5(const std::filesystem::path &file) {
std::string ret;
#include <iostream>
#include <string>
#include <vector>
struct Foo {
Foo() = default;
Foo(const Foo &f) : s(f.s) {
std::cout << "Copy constructor" << std::endl;
}
Foo(Foo &&f) : s(std::move(f.s)) {
#!/usr/bin/env bash
set -e
TIMES=10
EVENTS="task-clock,cycles,instructions,faults,cache-references,cache-misses,L1-dcache-loads,L1-dcache-load-misses,L1-dcache-stores,LLC-loads,LLC-load-misses,LLC-stores"
rm -f *.log
for i in $(seq 1 $TIMES)
do
#include <chrono>
#include <iostream>
int main() {
struct timespec n;
for (int i = 0; i < 20; ++i) {
auto now = std::chrono::system_clock::now();
auto now_ns = std::chrono::time_point_cast<std::chrono::nanoseconds>(now);
std::cout << "current nano: " << now_ns.time_since_epoch().count() << std::endl;
}
@syohex
syohex / sample_time.cpp
Created April 24, 2020 03:15
sample code of mach_absolute_time
#include <chrono>
#include <cstdio>
#include <cinttypes>
#include <mach/mach_time.h>
namespace {
void mach_ver() {
mach_timebase_info_data_t timebase_info;
mach_timebase_info(&timebase_info);
@syohex
syohex / test.md
Last active April 29, 2020 07:40
test.md
Error in user YAML: (<unknown>): did not find expected key while parsing a block mapping at line 1 column 1
---

aa: [link](https://example.com)
bb: hoge

---


[aa] [bb]