Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeremy Lu coodoo

View GitHub Profile
View SketchSystems.spec
Bus App
display
RELOAD -> loading
loading
LOAD_OK -> display
LOAD_FAIL -> error
error
RELOAD -> loading
View SketchSystems.spec
Gallery App
gallery
SEARCH -> loading
SELECT_PHOTO -> photo
RELOAD -> gallery
loading
CANCEL -> gallery
SEARCH_FAILED -> error
SEARCH_SUCCESS -> gallery
error
@coodoo
coodoo / fat.js
Created Aug 6, 2018
How to write fat arrow function.
View fat.js
import io from 'socket.io-client'
const A = require('automerge')
const foo = bar => {
bar.map( b => b.title )
}
startConnection() {
this.socket = io('http://localhost:5000')
@coodoo
coodoo / a.hs
Last active Jan 8, 2018
Find first not repeated char in a string. "Technical question" -> h. "Backend" -> b
View a.hs
-- f (x:xs) = case x `elem` xs of
-- True -> f xs
-- False -> x
f s = f' $ map toLower s
where
f' (x:xs) =
case x `elem` xs of
True -> f' xs
False -> x
View Interop2.hs
module Main where
import Control.Monad.State
import System.Directory
import System.Exit
import System.FilePath
import Data.Time
data File = File
{ name :: FilePath
@coodoo
coodoo / Interop.hs
Created Dec 9, 2017
Would appreciate any correction, better way to do it or generic advices on this practice code.
View Interop.hs
{-
Functionality:
- Read all folders and sub-folders with structure like below
- store all folder and file info in State monad,
- at the end of the loop, print it.
├── aaa
│ ├── b
│ │ ├── b1
│ │ │ ├── b1-1
@coodoo
coodoo / v3.hs
Created Oct 27, 2017
Convert list to tree using State monad, in a suck less manner 😅
View v3.hs
module Bar () where
import Data.Maybe
import Control.Monad.State
import qualified Data.Map as M
data Item = Item {
sId :: String,
pId :: String,
value :: [Char],
children :: [String]
@coodoo
coodoo / v2.hs
Created Oct 25, 2017
list to tree v2
View v2.hs
data Item = Item {
sId :: String,
pId :: String,
value :: [Char],
children :: [Item]
} deriving (Show)
list :: [Item]
list = [
Item { sId="1", pId="0", value="1", children=[] },
@coodoo
coodoo / v1.hs
Created Oct 25, 2017
convert list to tree structure
View v1.hs
data Item = Item {
sId :: String,
pId :: String,
value :: [Char],
children :: [String]
} deriving (Show)
list :: [Item]
list = [
Item { sId="1", pId="0", value="1", children=[] },
@coodoo
coodoo / WriterMonadExample.hs
Last active Oct 11, 2017
writer monad example
View WriterMonadExample.hs
module Bar
(
) where
import System.IO
import System.Environment
import Control.Monad
import Data.Maybe
import Data.List
import Control.Monad.Writer
You can’t perform that action at this time.