Skip to content

Instantly share code, notes, and snippets.

//
// 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
//
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
@googya
googya / youtube-dl-through.sh
Created January 25, 2018 01:24
youtube-dl through shadowsocks
youtube-dl --proxy socks5://127.0.0.1:1080 https://www.youtube.com/watch\?v\=GNtohfhj_A4
# 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|
module Apl1 where
import Control.Applicative
import Data.Monoid
data List a =
Nil
| Cons a (List a)
deriving (Eq, Show)
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
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)
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);
@googya
googya / monad.js
Last active September 5, 2017 08:20
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
@googya
googya / Redux-React-Counter-Example
Created July 19, 2017 06:46 — forked from rjmacarthy/Redux-React-Counter-Example
Redux and React Simple JSBIN
https://jsbin.com/debohu/1/edit?html,js,output