Skip to content

Instantly share code, notes, and snippets.

View behnammodi's full-sized avatar
:octocat:
...

Behnam behnammodi

:octocat:
...
View GitHub Profile
// goto https://github.com/behnammodi/ios-widget-global-calendar
@behnammodi
behnammodi / revision.js
Created October 22, 2020 13:45
For review
// -----------------------------------------------------------------------------------------
/**
* object literal
*/
const circle = {
r: 1,
draw: () => console.log('i draw'),
};
circle.draw();
<html>
<head>
<style>
#box {
width: 100px;
height: 100px;
background-color: lightseagreen;
}
</style>
</head>
@behnammodi
behnammodi / .bash_profile
Last active December 25, 2019 18:17
.bash_profile
# 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(){
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]}`
);
function sleep(seconds) {
const startTime = new Date();
const endTime = startTime.setSeconds(startTime.getSeconds() + seconds);
while (new Date() < endTime) {
continue;
}
return;
}
function useState(initialState) {
var _state = initialState;
function setState(value) {
_state = value;
}
function getState() {
return _state;
}
function sum(...num){
return num.reduce((a,b)=>a+b,0)
}
@behnammodi
behnammodi / actions.js
Last active August 6, 2019 10:04
Redux structure
export default {
ACTIONS_INC: state => ({
...state,
count: state.count + 1
}),
ACTIONS_DEC: state => ({ ...state, count: state.count - 1 })
};
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