Skip to content

Instantly share code, notes, and snippets.

View xiongxin's full-sized avatar
:bowtie:
Let It Go

熊鑫 xiongxin

:bowtie:
Let It Go
View GitHub Profile
@vsraptor
vsraptor / bin-tree.rs
Last active June 22, 2023 16:46
Rust : Binary tree
//based on the discussion here https://gist.github.com/aidanhs/5ac9088ca0f6bdd4a370
// Binary tree implementation (simplified)
#![allow(dead_code)]
use std::string::String;
use std::cmp::PartialEq;
use std::cmp::PartialOrd;
struct BinTree<T> {
@arrieta
arrieta / lexer.cpp
Last active May 3, 2024 13:06
Simple C++ Lexer
// A simple Lexer meant to demonstrate a few theoretical concepts. It can
// support several parser concepts and is very fast (though speed is not its
// design goal).
//
// J. Arrieta, Nabla Zero Labs
//
// This code is released under the MIT License.
//
// Copyright 2018 Nabla Zero Labs
//
@tikidunpon
tikidunpon / CodePiece.kt
Created August 30, 2017 11:53
雑だけどlocal functionでprintln定義してlinenumberだすやつ #CodePiece #read_kotlin
fun main(args: Array<String>) {
fun <T> println(message: T) {
print(Thread.currentThread().stackTrace[2].lineNumber.toString() + "行目 ")
print(message)
print("\n")
}
println("hi")
}
@eernstg
eernstg / GenericFunctionTypeAlias.md
Last active September 2, 2017 06:16
INFORMAL SPECIFICATION: Generic Function Type Alias

This document is now obsolete, please refer to the current version.

Feature: Generic Function Type Alias

Status: Under implementation.

This document is an informal specification of a feature supporting the definition of function type aliases using a more expressive syntax than the one available today, such that it also covers generic function types. The feature also introduces syntax for specifying function types directly, such

@chareice
chareice / validation.php
Created February 1, 2015 08:47
Localization Validation Message For Chineses With Laravel 5
<?php
use Symfony\Component\Yaml\Yaml;
return Yaml::parse(file_get_contents(base_path().'/resources/lang/zh_cn/validation.yml'));
@kiinlam
kiinlam / regex_example.txt
Last active July 26, 2022 13:04
正则匹配
正则匹配
匹配中文字符的正则表达式: [\u4e00-\u9fa5]
评注:匹配中文还真是个头疼的事,有了这个表达式就好办了
匹配双字节字符(包括汉字在内):[^\x00-\xff]
评注:可以用来计算字符串的长度(一个双字节字符长度计2,ASCII字符计1)
匹配空白行的正则表达式:\n\s*\r
评注:可以用来删除空白行
@nightire
nightire / How to use Backbone.js.md
Last active November 14, 2017 08:15
How to use Backbone.js

Simple Starting Point

创建 Model

var Person = Backbone.Model.extend();
@startling
startling / naive_sets.py
Created April 3, 2012 05:14
russell's paradox in python
class Set(object):
"""Sets can contain anything, including themselves. This leads to
paradoxical behavior: given R, the set of all sets that don't contain
themselves, does R contain R? Here this becomes an infinite recursion.
"""
def __init__(self, predicate):
self.predicate = predicate
def __contains__(self, obj):
return self.predicate(obj)