Skip to content

Instantly share code, notes, and snippets.

View novonimo's full-sized avatar
🏠
Working from home

Nima Mohamadian novonimo

🏠
Working from home
View GitHub Profile
@novonimo
novonimo / install-dart-on-windows.bat
Created March 23, 2019 14:49
Windows Script for "Set up your first Dart project on Windows"
REM Install Chocolatey package manager with cmd.exe
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
REM ..or Install Chocolatey package manager with Powershell.exe
REM Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
REM Install the Dart SDK
choco install dart-sdk
REM ..or Install the Dart SDK development version
@novonimo
novonimo / install-dart-on-linux.sh
Created March 23, 2019 14:32
Linux Script for "Set up your first Dart project on Linux"
# Update package repo listings
sudo apt-get update
# Enable access to repos using the HTTPS protocol
sudo apt-get install apt-transport-https
# Add Google linux sign in key to allow Dart repo registry
sudo sh -c 'curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -'
# Register Dart repo (release version)
@novonimo
novonimo / simpleRouter.js
Last active March 8, 2019 11:00
simple router with context api from scrach
import React, {Component} from 'react'
import {
Route,
Link,
Redirect,
BrowserRouter as Router
} from "react-router-dom";
const HomePage = () => {
return (
@novonimo
novonimo / simpleRouter.js
Created March 8, 2019 09:27
simple router with context api from scrach
import React, {Component} from 'react'
import createHistory from 'history/createBrowserHistory'
const RouterContext = React.createContext();
class Router extends Component {
constructor(props){
super(props);
this.history = createHistory();
@novonimo
novonimo / RenderProps
Last active March 7, 2019 14:11
render Props pattern for avoiding anti pattern
import React, {Component} from 'react'
const Third = (props) => {
return (
<div>
<h3>Third</h3>
<p>Number: {props.number}</p>
<p>Text: {props.text}</p>
</div>
)
@novonimo
novonimo / ActiveDetail.js
Last active March 7, 2019 16:12
complete example of HOC (higher order component)
import React, {Component} from 'react'
import withActiveDetail from './withActiveDetail'
class ActiveDetail extends Component {
render() {
return (
<div>
<h3>Active Detail</h3>
<div style={{backgroundColor: this.props.isOnline? this.props.isOnlineColor: this.props.isOfflineColor}}>
{this.props.isOnline? 'Online': 'Offline'}
@novonimo
novonimo / mouseTracker.moduel.css
Created March 7, 2019 08:44
simple mouse tracker version 1
.mainFrame{
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
}
.rectangle{
border: 5px solid black;
width: 400px;
@novonimo
novonimo / functionBaseTimer.js
Last active March 6, 2019 14:51
function base hook Timer
import React, {useState, useCallback} from 'react'
import styles from '../timer/timer.module.css'
let intervalId = null;
export default function FunctionalTimer() {
let [value, setValue] = useState(0);
let [started, setStarted] = useState(false);
const toggle = useCallback(() => {
if (started) pause();
@novonimo
novonimo / app.js
Created March 6, 2019 13:20
counter with lifecycle method
import React, {Component} from 'react';
import './App.css';
import Timer from './component/timer/timer'
import Counter from './component/counter/counter'
export default class App extends Component {
render() {
return (
<div className="App">
<Counter min={0} max={10}/>
@novonimo
novonimo / simpleTimer.js
Created March 6, 2019 09:00
complete Timer logic with react
import React, {Component} from 'react'
import styles from './timer.module.css'
export default class Timer extends Component {
state = {
timerValue: 0
};
intervalId = null;