Skip to content

Instantly share code, notes, and snippets.

View Huxpro's full-sized avatar
🤔
Still making sense of JavaScript

Xuan Huang (黄玄) Huxpro

🤔
Still making sense of JavaScript
View GitHub Profile
@Huxpro
Huxpro / js_interp_bench.md
Last active December 13, 2020 21:23
JS interpreter performance

JS interpreter performance

On Macbook Pro 16"

Native

λ v8 --jitless benchmark.js
Richards: 1147
Crypto: 845
CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only perfomed in repo update
Updating spec repo `trunk`
CDN: trunk Relative path: deprecated_podspecs.txt, has ETag? W/"5fd0a021-7b4c0"
CDN: trunk Relative path not modified: deprecated_podspecs.txt
CDN: trunk Going to update 14 files
CDN: trunk Relative path: all_pods_versions_e_d_6.txt, has ETag? W/"5fd09df2-266"
CDN: trunk Relative path: all_pods_versions_3_2_5.txt, has ETag? W/"5fd09df2-593"
CDN: trunk Relative path: all_pods_versions_5_d_0.txt, has ETag? W/"5fd09df2-2d8"
CDN: trunk Relative path: all_pods_versions_2_7_2.txt, has ETag? W/"5fd09df2-3d3"
@Huxpro
Huxpro / gist:3c3bbea3c6f597dc857e60df76800f8c
Created November 2, 2020 19:41
env USE_FRAMEWORKS=1 USE_HERMES=1 pod install
react-native/packages/rn-tester git/feat/ios-hermes-try*
λ env USE_FRAMEWORKS=1 USE_HERMES=1 pod install
Installing pods with use_frameworks!
Using Hermes engine
Analyzing dependencies
Fetching podspec for `libevent` from `../../third-party-podspecs/libevent.podspec`
Downloading dependencies
Installing RCT-Folly 2020.01.13.00
Installing React-Core 1000.0.0
Installing hermes-engine (0.7.1)
/**
class Super {
x = "super"
}
*/
class Super {
constructor() {
@Huxpro
Huxpro / EmulateESNextClass.js
Last active September 22, 2020 09:27
Emulate ES Next Class
// 试了两种方式模拟:
class Super {
constructor() {
this.x = "super"
}
};
// 这样的话也是 own property
new Super().hasOwnProperty('x') // true
@Huxpro
Huxpro / TextInput.dart
Created April 8, 2020 00:16
A Flutter TextField that maintain selection state like TextInput in React Native
import 'package:flutter/material.dart';
/// A TextField that maintain selection state like React Native
class TextInput extends StatefulWidget {
TextInput({@required this.decoration, @required this.text, @required this.onChanged});
final String text;
final InputDecoration decoration;
final Function onChanged;
{-# LANGUAGE
GADTs,
ExistentialQuantification
#-}
import Control.Monad
import Data.IORef
import Data.Sequence
import Data.Foldable

OK, so today I was looking at Writer monad, a very basic Monad.

In its essence, it's just a Monad that outputs (e.g. log) something,
The "Variation three: Output" Monad from the original Monads for functional programming, 92 paper is very lean:

type M a = (Output, a)
type Output = String

Hi folks, I just wanna share my story on my first day trying Cabal/Stack.

So I was learning Haskell for half a semester but only live within ghci and runhaskell. But today I was thinking of playing with /write-you-a-haskell/chapter4/untyped so I pulled it down.

I was first trying to follow the README.md which asked me to do cabal run. It failed and gave me errors on the ambiguous usage of <>, I realized cabal is using my global GHC version and it might be some breaking changes there. (since it's Haskell)

I heard stack can solve this problem by having multiple GHC so I changed to looking into that. So I run stack build, see the new GHC being downloaded, but failed. The resolver of the project is 7.8.4 and the problem is ar permission errors on OS X 10.11 El Capitan with GHC 7.8.4 . I tried several workarounds posted in the issue page but none of them works.

Aft

module type Set = sig
type 'a t
val empty : 'a t
val isEmpty : 'a t -> bool
end
module ListSet : Set = struct
type 'a t = 'a list
let empty = []
let isEmpty l = l == []