View ios-widget-global-calendar.js
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
// goto https://github.com/behnammodi/ios-widget-global-calendar |
View revision.js
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
// ----------------------------------------------------------------------------------------- | |
/** | |
* object literal | |
*/ | |
const circle = { | |
r: 1, | |
draw: () => console.log('i draw'), | |
}; | |
circle.draw(); |
View raf.html
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
<html> | |
<head> | |
<style> | |
#box { | |
width: 100px; | |
height: 100px; | |
background-color: lightseagreen; | |
} | |
</style> | |
</head> |
View .bash_profile
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
# Git branch in prompt. | |
function parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
function number_of_uncommited(){ | |
git status -s 2> /dev/null | wc -l | awk '{$1=$1};1' | grep -v "^0" | |
} | |
function color_blue(){ |
View ptf.js
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
import is from "is"; | |
function ptf(fun, configs) { | |
if (is.array(configs)) | |
return (...args) => { | |
configs.forEach((_, index) => { | |
if (configs[index](args[index]) === false) | |
throw new Error( | |
`${index} argument type is error, ${index} value is ${args[index]}` | |
); |
View block-thread.js
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 sleep(seconds) { | |
const startTime = new Date(); | |
const endTime = startTime.setSeconds(startTime.getSeconds() + seconds); | |
while (new Date() < endTime) { | |
continue; | |
} | |
return; | |
} |
View useState.js
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 useState(initialState) { | |
var _state = initialState; | |
function setState(value) { | |
_state = value; | |
} | |
function getState() { | |
return _state; | |
} |
View sum-infinite.js
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 sum(...num){ | |
return num.reduce((a,b)=>a+b,0) | |
} |
View actions.js
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
export default { | |
ACTIONS_INC: state => ({ | |
...state, | |
count: state.count + 1 | |
}), | |
ACTIONS_DEC: state => ({ ...state, count: state.count - 1 }) | |
}; |
View react-useglobalstate.js
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
import React, { useReducer, createContext, useContext, useEffect } from "react"; | |
import { on, emit } from "jetemit"; | |
const initialValue = { X: 0, Y: 0 }; | |
const reducer = (state, action) => { | |
switch (action.type) { | |
case "+": | |
return { | |
...state, | |
X: state.X + 1 |
NewerOlder