Skip to content

Instantly share code, notes, and snippets.

:octocat:
. . .

Behnam Mohammadi uxitten

:octocat:
. . .
Block or report user

Report or block uxitten

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View algorithmes.js
/*
* Commons array
* when array is sorted
*/
function commons(a, b) {
const result = [];
let i = j = 0;
cancel:while (true) {
if (a[i] > b[j]) j++;
else if (a[i] < b[j]) i++;
@uxitten
uxitten / memoize.js
Created Jul 1, 2019
Memoized function for better performance
View memoize.js
/**
* @description memoized function for better performance
* @param {function} func
* @returns {function} func
*/
function memoize(func) {
var cache = {};
return function() {
var id = JSON.stringify(arguments);
if (cache[id] === undefined)
@uxitten
uxitten / react-redux-sample.js
Last active May 12, 2019
React Redux Sample
View react-redux-sample.js
import React from "react";
import { createStore } from "redux";
import { connect, Provider } from "react-redux";
const ACTIONS_INC = "ACTIONS_INC";
const ACTIONS_DEC = "ACTIONS_DEC";
function counter(state = { count: 0 }, { type }) {
const actions = {
[ACTIONS_INC]: () => ({ count: state.count + 1 }),
@uxitten
uxitten / react-guard-router.js
Last active Mar 4, 2019
Sample guard router for react
View react-guard-router.js
import React, { Component } from "react";
import {
BrowserRouter,
Route,
Switch,
Link,
Redirect,
withRouter
} from "react-router-dom";
@uxitten
uxitten / gitexec.js
Created Feb 20, 2019
run git command with nodejs
View gitexec.js
const {exec} = require('child_process');
function git(args) {
return new Promise(res => {
exec('git ' + args, (err, stdout, stderr) => {
if (err) {
throw err;
} else {
res(stdout.trim());
}
@uxitten
uxitten / nginx-proxy.sh
Created Dec 11, 2018
nginx proxy sample
View nginx-proxy.sh
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
@uxitten
uxitten / queue.js
Last active Nov 19, 2018
async queue in javascript
View queue.js
let count = 0;
let running = false;
const queue = {};
const addTask = task => {
queue[count++] = task;
if (running === false) runTasks();
}
const runTasks = async () => {
@uxitten
uxitten / utils.js
Last active Jul 5, 2019
utils file
View utils.js
/**
* @private
*/
const FA = 0;
/**
* @private
*/
const EN = 1;
/**
* @private
You can’t perform that action at this time.