Skip to content

Instantly share code, notes, and snippets.

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

Lucas xianminx

🏠
Working from home
View GitHub Profile
@xianminx
xianminx / products.ts
Created August 25, 2023 04:45
solid-createResource
const fetchProducts = async () => {
const res = await fetch('https://fakestoreapi.com/products');
const data = await res.json();
return data;
}
export default function ProductList() {
const [products] = createResource(() =>
fetchProducts()
);
@xianminx
xianminx / README.md
Created August 8, 2019 16:03 — forked from atenni/README.md
How to permalink to a gist's raw file

Problem: When linking to the raw version of a gist, the link changes with each revision.

Solution:

To return the first file from a gist: https://gist.github.com/[gist_user]/[gist_id]/raw/

To get a file from multi–file gist: https://gist.github.com/[gist_user]/[gist_id]/raw/[file_name]

@startuml component
actor client
node app
database db
db -> app
app -> client
@enduml
@xianminx
xianminx / custom_event.js
Created August 21, 2018 03:27
Javascript custom event
var event = new Event('custom_event')
var elem = document.getElementById('custom-event-elem')
function handler(){
console.log('custom event triggered!')
}
elem.addEventListener('custom_event', handler, false)
elem.dispatchEvent(event)
function hello_axios() {
const axios = require('axios');
axios.get('https://cityapi.opentown.cn/events/5b3a2aed66db7502c0a2760x').then(function (response) {
console.log(response);
}).catch(function (error) {
console.log(error);
}).then(function () {
console.log('always executed')
@xianminx
xianminx / Ballot.sol
Created May 24, 2018 06:33
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.24+commit.e67f0147.js&optimize=false&gist=
pragma solidity ^0.4.20;
/// @title Voting with delegation.
contract Ballot {
// This declares a new complex type which will
// be used for variables later.
// It will represent a single voter.
struct Voter {
uint weight; // weight is accumulated by delegation
bool voted; // if true, that person already voted
@xianminx
xianminx / TestProcessPool.py
Created January 21, 2018 13:12
weird clocking in python datetime.now()
from concurrent.futures import ProcessPoolExecutor
import random,os
from datetime import datetime
import multiprocessing
from multiprocessing import Process, Queue, Manager
from multiprocessing.sharedctypes import Value, Array
import time, random
import threading
@xianminx
xianminx / App$.java
Created April 16, 2016 10:18
scala implicit conversions
public final class App$
{
public static final MODULE$;
private final int someInt;
static
{
new ();
}
@xianminx
xianminx / nc.log
Last active April 7, 2016 08:06
一些简单的Linux 工具 - netcat / nc
nc — arbitrary TCP and UDP connections and listens
➜ Downloads nc baidu.com 80
GET / HTTP/1.1
User-Agent: curl/7.38.0
Host: baidu.com
Accept: */*
HTTP/1.1 200 OK
// use Akka actor
case class BatchTask(id: Int)
class TaskActor extends Actor {
def receive = {
case BatchTask(batchId) => new TaskWorker().run(batchId)
}
}
val taskWorker = context.actorOf(Props[TaskActor])