Skip to content

Instantly share code, notes, and snippets.

View firstfu's full-sized avatar
🧸
Focusing

firstfu firstfu

🧸
Focusing
  • Taiwan
View GitHub Profile
@Eunovo
Eunovo / JobProcessor.ts
Last active January 9, 2022 10:13
Code describing a system to handle CPU-intensive jobs on NodeJS servers
class JobProcessor {
private assignedJobs = new Map<String, any>();
private queue = new Queue<any>();
private nWorkers = 5;
async loadOutstandingJobs() {
// load 'pending' or 'processing' jobs from DB
const jobs = await services.Job
.findMany({
$or: [
@dabit3
dabit3 / NFT.sol
Last active March 6, 2022 22:44
Basic NFT Smart Contract
// contracts/NFT.sol
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.8.3;
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "hardhat/console.sol";
@lennardv2
lennardv2 / 1. Building PHP-MAMP on Apple Silicon M1.md
Last active February 29, 2024 07:57
Native PHP development / MAMP stack on Apple silicon M1

Building the MAMP stack (php, apache & mysql) on Apple Silicon ARM (native)

Update! This tutorial is outdated. Nowadays brew installes m1 binaries just fine. Also use valet: https://laravel.com/docs/9.x/valet. It's 10x easier.

In this tutorial, we'll build the the nescessary packages for ARM via homebrew. After that we'll configure apache2 for using virtual hosts. The native php is ofcourse way faster, see the results of this benchmark below.

TEST NAME SECONDS OP/SEC
@taichunmin
taichunmin / flex-dice.json
Created June 13, 2020 20:19
能使用變數的 LINE 訊息推送小工具
{
"type": "bubble",
"hero": {
"type": "image",
"url": "https://scdn.line-apps.com/n/channel_devcenter/img/fx/01_1_cafe.png",
"size": "full",
"aspectRatio": "20:13",
"aspectMode": "cover"
},
"body": {
@afparsons
afparsons / pprint_queryset.py
Last active August 24, 2023 08:06
Django QuerySet PrettyPrint
# Enhanced Django QuerySet printing using PrettyPrinter
# Example usage: dropped into and employed within an IPython notebook.
# --- PRETTYPRINT -------------------------------------------------------------
# A PrettyPrinter object contains a _dispatch dictionary.
# This lookup table contains (key, value) pairs wherein the key corresponds to
# an object's __repr__ method, and the value is a special _pprint_<OBJECT>
# method. The PrettyPrint method pprint() queries the dictionary to call the
# appropriate object printer.
# 單行聲明變量
let x = 5, y, z = 4
## null 表示無值
## undefined 表示沒有定義的變數
##變數設定為- undefined
bartimer = void 0;
##判斷變數如果不為undefined,則變數設定為undefined
if (typeof bartimer != 'undefined'){
bartimer = void 0;
##去除數字後多除0
$disPrice = rtrim(rtrim($disPrice, '0'), '.');
# 高精度浮點數計算
#減
$disPrice = bcsub($numA, $numB, 2);
import tensorflow as tf
import pandas as pd
import numpy as np
from scipy import stats
import itertools
import matplotlib.pylab as plt
# 白努力分配
size = 10000
p = 0.4