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 |
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(); |
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> |
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(){ |
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]}` | |
); |
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; | |
} |
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; | |
} |
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) | |
} |
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 }) | |
}; |
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