Skip to content

Instantly share code, notes, and snippets.

View huruji's full-sized avatar
☂️
被社会毒打的频率奇高

忽如寄 huruji

☂️
被社会毒打的频率奇高
View GitHub Profile
const { dirname, sep, join, resolve } = require('path')
const { build } = require('esbuild')
const { readFile } = require('fs/promises')
// TODO: Check how to solve when [dir] or [hash] are used
function pinoPlugin(options) {
options = { transports: [], ...options }
return {
name: 'pino',
@fxm90
fxm90 / CheckboxToggleStyle.swift
Last active March 31, 2023 17:38
A fully configurable toggle style for SwiftUI, making the Toggle look like a checkbox.
//
// CheckboxToggleStyle.swift
//
// Created by Felix Mau on 25.05.2021.
// Copyright © 2021 Felix Mau. All rights reserved.
//
/// A fully configurable toggle style for SwiftUI, making the Toggle look like a checkbox.
struct CheckboxToggleStyle: ToggleStyle {
@samredai
samredai / install_pipenv.sh
Created August 12, 2019 18:50
Python: Solution to 'Pipenv: Command Not Found' After 'pip install pipenv'
sudo -H pip install -U pipenv
# If you did a user install because you do not have sudo access, you have to modify your path to add your user folder
# The command on the next line tells you where your user folder is
# python3 -m site --user-base
PYTHON_BIN_PATH="$(python3 -m site --user-base)/bin"
PATH="$PATH:$PYTHON_BIN_PATH"
import JavaScriptCore
import Foundation
let context = JSContext()!
import JavaScriptCore
@objc protocol MovieJSExports: JSExport {
var title: String { get set }
var price: String { get set }
@aeschright
aeschright / npm-strike.md
Last active September 8, 2021 16:32
A note about npm cli work status

When will npm@6.9.1 be released (and other PRs merged?)

On March 22, npm fired several members of the open source and community team for discussing workplace conditions and other labor organizing activities. As a result, core employee contributors to the npm cli were removed from the project, and others have left in solidarity or put their work on hold.

Multiple claims were filed with the NLRB on this matter. The NLRB has investigated and found sufficient evidence of validity to proceed. The National Labor Relations Act of 1935 protects US employees' right to engage in discussions of workplace concerns without threat of retaliation -- and awareness of the importance of how we treat each other is something I valued so much in collaborating with the cli team. How can we work together if we aren't free to discuss what we need?

It's disappointing for all of us to find the work we were doing interrup

@byevhen2
byevhen2 / Build both .js and .min.js with webpack.md
Last active October 22, 2022 11:58
How to build both minified and uncompressed bundle with Webpack

Q: How to build both minified and uncompressed bundle with Webpack?

A1: Use plugin UglifyJsPlugin (before webpack 4)

let webpack = require("webpack");

module.exports = {
    entry: {
        'bundle': './entry.js',
 'bundle.min': './entry.js'
@huruji
huruji / validator-proxy.js
Last active October 8, 2018 18:17
A simple fluent validator using Proxy
var proxyContext = function(ctx) {
return new Proxy(ctx, {
get(obj, prop) {
if (prop in obj) {
return obj[prop];
}
const newCtx = proxyContext(ctx.clone());
if (prop in rules) {
let re = newCtx.addRule(rules[prop]);
return re;
@huruji
huruji / miniPromise.js
Created July 13, 2018 17:51
a deom for Promise
function Promise(excutor) {
let self = this;
self.status = 'pending';
self.value = null;
self.reason = null;
self.onFulfilledCallbacks = [];
self.onRejectedCallbacks = [];
function resolve(value) {
if(self.status === 'pending') {
@zxhfighter
zxhfighter / debug.md
Created April 2, 2018 03:15
debug node app

调试 Node 程序

[TOC]

本文介绍的两个调试方法需要 Node 版本大于 6.3.0.

待调试程序

我们来调试下最经典的迷你服务器程序,新建一个文件 app.js,输入内容如下:

@YiqinZhao
YiqinZhao / question-1.js
Last active June 20, 2019 13:38
[yuanfudao-interview] 猿辅导前端面试总结 #interview
let N = 10
let source = []
let M = 4
for (let i = 0; i < N; i++) {
let len = Math.floor(Math.random() * 5) + 5
let item = []
for (let j = 0; j < len; j++) item.push(Math.floor(Math.random() * 10))
source.push(item)