Skip to content

Instantly share code, notes, and snippets.

View yanickxia's full-sized avatar
:octocat:
Play with Rust

Yanick.xia yanickxia

:octocat:
Play with Rust
View GitHub Profile
@yanickxia
yanickxia / addTypeInformationToObject.go
Created November 22, 2020 12:12
k8s-addTypeInformationToObject
// addTypeInformationToObject adds TypeMeta information to a runtime.Object based upon the loaded scheme.Scheme
// inspired by: https://github.com/kubernetes/cli-runtime/blob/v0.19.2/pkg/printers/typesetter.go#L41
func addTypeInformationToObject(obj runtime.Object) error {
gvks, _, err := scheme.Scheme.ObjectKinds(obj)
if err != nil {
return fmt.Errorf("missing apiVersion or kind and cannot assign it; %w", err)
}
for _, gvk := range gvks {
if len(gvk.Kind) == 0 {
@yanickxia
yanickxia / anync.rs
Created September 4, 2020 10:05
Rust Async
#![allow(unused)]
use {
futures::{
future::{BoxFuture, FutureExt},
task::{ArcWake, waker_ref},
},
std::{
future::Future,
pin::Pin,
@yanickxia
yanickxia / toggl-tomator.js
Last active July 17, 2020 13:24
toggl-tomator
// ==UserScript==
// @name add tomator timer for toggle
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author yanick
// @match toggl.com/*
// @match app.clickup.com/*
// @grant GM_addStyle
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
@yanickxia
yanickxia / bfs.java
Created April 9, 2018 07:11
BFS & DFS
import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;
public class TreeSearch {
public static void depthFirstSearchWithStack(int[][] adjMatrix) {
boolean[] visitors = new boolean[adjMatrix.length];
Stack<Integer> stack = new Stack<>();
@yanickxia
yanickxia / docker-compose.yml
Created January 9, 2018 15:14
gitlab-dockercompse
web:
image: 'gitlab/gitlab-ce:latest'
restart: always
hostname: 'gitlab.example.com'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://git.mschina.io'
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = 'smtp.mailgun.org'
gitlab_rails['smtp_port'] = 587
@yanickxia
yanickxia / Final_Method_In_Abstart_Class.java
Created December 9, 2015 02:31
Final_Method_In_Abstart_Class
public abstract class BaseLoaneeRepayment implements Repayment {
@Autowired
protected LoanRepository loanRepository;
@Transactional(propagation = Propagation.REQUIRES_NEW)
public final void repay(RepaymentInfo repaymentInfo) {
Loan loan = loanRepository.lockAndLoad(repaymentInfo.getLoan().id());
}
protected abstract void preCheck(final RepaymentInfo repaymentInfo);