Skip to content

Instantly share code, notes, and snippets.

View ray1422's full-sized avatar

Ray1422 ray1422

  • Taiwan
View GitHub Profile
@ray1422
ray1422 / async.go
Created November 24, 2023 18:08
impl async in Go
package async
// Future for async
// usage:
// // define a function
//
// func f() Future[int] {
// return Ret(1)
// }
//
class Solution:
EPLISON_TOKEN = "&"
FINAL_TOKEN = "$"
def __init__(self):
self.states = [
# [ [char, ID], [char, ID], ... ]
]
self.s = ""
def search(self, s_start, state_idx) -> bool:
#include <bits/stdc++.h>
template <typename T, unsigned... S>
class Tensor;
// define Tensor with variable shape
template <typename T, unsigned... S>
class Tensor {
public:
// output stream operator for Shape
template <typename Y, unsigned... Z>
@ray1422
ray1422 / timer.h
Last active May 6, 2021 09:59
Timer Macro for C
#pragma once
#include <string.h>
#include <sys/time.h>
#include <time.h>
inline static struct timespec diff(struct timespec start, struct timespec end) {
struct timespec temp;
if ((end.tv_nsec - start.tv_nsec) < 0) {
temp.tv_sec = end.tv_sec - start.tv_sec - 1;
temp.tv_nsec = 1000000000 + end.tv_nsec - start.tv_nsec;
} else {
[step: 0] Accuracy: 14.88315%, Best: 14.88315%
[step: 200] Accuracy: 37.39237%, Best: 37.39237%
[step: 400] Accuracy: 39.85240%, Best: 39.85240%
[step: 600] Accuracy: 55.35055%, Best: 55.35055%
[step: 800] Accuracy: 71.83272%, Best: 71.83272%
[step: 1000] Accuracy: 75.27675%, Best: 75.27675%
[step: 1200] Accuracy: 84.74784%, Best: 84.74784%
[step: 1400] Accuracy: 82.65682%, Best: 84.74784%
[step: 1600] Accuracy: 87.82288%, Best: 87.82288%
[step: 1800] Accuracy: 88.43789%, Best: 88.43789%
@ray1422
ray1422 / compton.conf
Created December 25, 2019 02:19
my compton config
#################################
#
# Backend
#
#################################
# Backend to use: "xrender" or "glx".
# GLX backend is typically much faster but depends on a sane driver.
backend = "glx";
k = int(input())
my_str = input()
canvas = [0] * len(my_str)
# step one: mark all the "switch point"
# for a example, aAbBcCdD, mark the 'a' of aA, 'A' of Ab
for i in range(len(my_str) - 1):
if (my_str[i].islower() and my_str[i + 1].isupper()) or (my_str[i].isupper() and my_str[i + 1].islower()):
@ray1422
ray1422 / b024.cpp
Created September 16, 2019 10:22
Green Judge b024
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
long long int fa(long long int n) {
long long int sum = n;
for(int i = 1;i < n; i++) {
sum *= i;

Keybase proof

I hereby claim:

  • I am ray1422 on github.
  • I am ray1422 (https://keybase.io/ray1422) on keybase.
  • I have a public key ASAPt50755nLqXvyEDl99jOzGGfxRvVfkvL1Wf6l3-s92go

To claim this, I am signing this object:

@ray1422
ray1422 / test
Created August 23, 2017 19:39
test
test