Skip to content

Instantly share code, notes, and snippets.

View quiye's full-sized avatar
🏠
Working from home

Ishida Yuya quiye

🏠
Working from home
View GitHub Profile
@quiye
quiye / json_loader.py
Created July 5, 2021 19:27
json arg searcher
import json
from typing import Dict, List, Any
import sys
if len(sys.argv) != 2:
raise Exception("invalid args")
id = sys.argv[1]
def check(name: str, a: Any, isPrintable: bool = False, path: str = "") -> None:
@quiye
quiye / stopWatch.hpp
Created June 13, 2020 03:02
simple stop watch (timer)
class stopWatch {
private:
decltype(std::chrono::high_resolution_clock::now()) start = std::chrono::high_resolution_clock::now();
public:
~stopWatch() {
const auto finish = std::chrono::high_resolution_clock::now();
const auto durationMilliSeconds = std::chrono::duration_cast<std::chrono::milliseconds>(finish - start).count();
std::cout << durationMilliSeconds << " ms" << std::endl;
}
@quiye
quiye / yjy.md
Last active April 21, 2024 23:25
yaml to jsonnet to yaml
@quiye
quiye / move.cpp
Created November 29, 2019 16:47
move
#include <bits/stdc++.h>
using namespace std;
struct something {
~something() {
cout << "destructor" << endl;
}
};
something&& f(something&& s) {
@quiye
quiye / msgpack.go
Created July 27, 2019 05:33
msgpackの練習
package main
import (
"log"
"math"
"github.com/vmihailenco/msgpack"
)
func main() {
@quiye
quiye / sqlite.py
Last active May 19, 2018 04:11
sqliteのデモ
import sqlite3
import json
conn = sqlite3.connect(':memory:')
c = conn.cursor()
c.execute('''CREATE TABLE stocks
(date text, trans text, symbol text, qty real, price real, json text, id integer primary key AUTOINCREMENT)''')
c.execute(
"INSERT INTO stocks(date, trans, symbol, qty, price, json) VALUES ('2006-01-05','BUY','RHAT',100,35.14,'{\"name\":\"太郎1\"}')")
purchases = [('2006-03-28', 'BUY', 'IBM', 1000, 45.00, '{"name":"太郎2"}'),
@quiye
quiye / ?.scala
Created April 13, 2018 11:19
?.scala
scala> List(1,2,3).map({println("1");_+1}).map({println("a"); _+1})
1
a
res21: List[Int] = List(3, 4, 5)
scala> List(1,2,3).map({println("1");_+1}).map(a=>{println("a"); a+1})
1
a
a
a
@quiye
quiye / k2HASHSample.cpp
Created April 11, 2018 22:09
K2HASHの使用デモ
#include <fstream>
#include <iostream>
#include <k2hash/k2hash.h>
#include <k2hash/k2hshm.h>
#include <sstream>
using namespace std;
int main() {
K2HShm k;
cout << k.GetSystemPageSize() << endl;
@quiye
quiye / ByteArrayToFloatList.scala
Created April 11, 2018 13:34
4bytes => Float
scala> import java.nio.ByteBuffer
import java.nio.ByteBuffer
scala> val b = Array(1,2,3,4,5,6,7,8,0,0,0,0).map(_.toByte)
b: Array[Byte] = Array(1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0)
scala> b.grouped(4).foldRight(Nil: List[Float])(ByteBuffer.wrap(_).getFloat::_)
res8: List[Float] = List(2.3879393E-38, 6.301941E-36, 0.0)
@quiye
quiye / Type.md
Last active March 22, 2018 14:56
scala練習

キャストは慎重に

scala> val a: Any = List(1,2,3)
a: Any = List(1, 2, 3)

scala> val d=a.asInstanceOf[List[Long]]
d: List[Long] = List(1, 2, 3)

scala> val e=a.asInstanceOf[List[Int]].map(_.toLong)
e: List[Long] = List(1, 2, 3)