Skip to content

Instantly share code, notes, and snippets.

View Axure's full-sized avatar
😃
Time is money

Hu Zheng Axure

😃
Time is money
View GitHub Profile
if (a+3 ) {
a -= 3;
}
else{
a*= 3
}
@Axure
Axure / index.html
Created February 9, 2018 06:15
host in DOM
<button class="red">My Button</button>
<script>
var button = document.querySelector('button');
var root = button.createShadowRoot();
root.innerHTML = '<style>' +
':host { text-transform: uppercase; }' +
'</style>' +
'<content></content>';
console.log(root.host);
</script>
@Axure
Axure / crawl.go
Created January 7, 2018 09:06
A plausible solution to the crawler exercise of the Go tour
package main
import (
"fmt"
"sync"
)
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on that page.
@Axure
Axure / graphql-decorators-before.ts
Last active November 28, 2017 15:49 — forked from anonymous/graphql-decorators.ts
GraphQL with decorators.
export const rootMutationType = new GraphQLObjectType({
name: 'MutationRoot',
fields: () => ({
addWord1: {
args: {
value: {
name: 'value',
type: new GraphQLNonNull(GraphQLString),
},
},
@Axure
Axure / init.sh
Last active November 25, 2017 12:24
VPS Production Script
sudo apt update
sudo apt install --install-recommends linux-generic-hwe-16.04
sudo echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
sudo echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sudo sysctl -p
sudo apt install git zsh nginx
sudo sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt install -y nodejs
sudo apt install software-properties-common
@Axure
Axure / Peano.idr
Last active October 13, 2017 07:26
Idris Question
%hide Prelude.Interfaces.(<=)
data Peano : Type where
O: Peano
(++): Peano -> Peano
total
(+): Peano -> Peano -> Peano
(+) O x = x
(+) ((++)x) y = (++)(x + y)
@Axure
Axure / App.scala
Last active October 7, 2017 20:21
Modules in OCaml
trait Lazy[T[_]] {
type Type[X] = T[X]
def mk[A](thunk: () => A): T[A]
}
object LazyThunk extends Lazy[({type Thunk[X] = () => X})#Thunk] {
override def mk[A](thunk: () => A): () => A = thunk
}
@Axure
Axure / main.cpp
Last active May 19, 2022 02:53
Type level programming in C++
#include <iostream>
/**
*
def checksum(l: List[Int]): Int = l.reverse.zipWithIndex.map {
case (v, i) => v * (i + 1)
}.sum % 11
def isValid(l: List[Int]): Boolean = l.size == 9 && checksum(l) == 0
isValid(List(3, 4, 5, 8, 8, 2, 8, 6, 5)) // true
@Axure
Axure / rusty-c++.cpp
Last active April 9, 2017 15:48
Rusty C++
#include <iostream>
struct MyTrait;
struct AnotherTrait;
struct YetAnotherTrait;
struct RubbishTrait;
template <class ... Traits>
struct MyTypeWithTrait {};
@Axure
Axure / Interpreter.scala
Created March 25, 2017 20:44 — forked from ezksd/Interpreter.scala
interpreter
package ezksd
import ezksd.Parser.parse
object Interpreter {
type Continuation[T] = T => Unit
@inline
def cps_map(l: List[Any], f: (Any, Any => Unit) => Unit, k: Continuation[List[Any]]) {