This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Method to normalize size of fonts across devices | |
// | |
// Some code taken from https://jsfiddle.net/97ty7yjk/ & | |
// https://stackoverflow.com/questions/34837342/font-size-on-iphone-6s-plus | |
// | |
// author: @xiaoneng | |
// date: 14/10/2016 | |
// version: 03 | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reg_obj = Regexp.new('([a-z]*\.?){1,3}\.ishanggang\.com') | |
s = `ag "#{reg_obj.to_s}"` | |
lines = s.split(/\t|\n/) | |
res = lines.each_with_object([]) do |e, arr| | |
if e =~ reg_obj | |
arr << $~.to_s | |
end | |
end.uniq.sort |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
youtube-dl --proxy socks5://127.0.0.1:1080 https://www.youtube.com/watch\?v\=GNtohfhj_A4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# find files and create a json file | |
require 'json' | |
reg = /import (?:{)?\s*(\w*)\s*(?:})? from '@ui\// | |
entries = `ag -l '@ui/' /Users/le/src` | |
entries_ary = entries.split("\n") | |
json = entries_ary.each_with_object({}) do |filename, obj| | |
names = [] | |
File.open(filename, 'r') do |f| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Apl1 where | |
import Control.Applicative | |
import Data.Monoid | |
data List a = | |
Nil | |
| Cons a (List a) | |
deriving (Eq, Show) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Ex where | |
newtype Flip f a b = | |
Flip (f b a) | |
deriving (Eq, Show) | |
newtype K a b = | |
K a | |
deriving (Eq, Show) | |
instance Functor (Flip K a) where |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module BinaryTree where | |
data BinaryTree a = | |
Leaf | |
| Node (BinaryTree a ) a (BinaryTree a) | |
deriving (Eq, Ord, Show) | |
insert' :: Ord a => a -> BinaryTree a -> BinaryTree a | |
insert' b Leaf = Node Leaf b Leaf | |
insert' b (Node left a right) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doubleAfter2Seconds(x) { | |
return new Promise((resolve, reject) => { | |
resolve(x * 2) | |
}, 2000) | |
} | |
async function addAsync(x) { | |
const a = doubleAfter2Seconds(10); | |
const b = doubleAfter2Seconds(20); | |
const c = doubleAfter2Seconds(30); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const curry = require('ramda').curry | |
var Monad = function(type, defs) { | |
for (name in defs){ | |
type.prototype[name] = defs[name]; | |
} | |
return type; | |
}; | |
function Left(value){ | |
this.value = value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://jsbin.com/debohu/1/edit?html,js,output |