Skip to content

Instantly share code, notes, and snippets.

View qti3e's full-sized avatar
😃

Parsa qti3e

😃
View GitHub Profile
@qti3e
qti3e / withWindowDimensions.js
Created January 28, 2018 12:11
withWindowDimensions React.js HOC
import React, {Component} from 'react'
import hoistNonReactStatic from 'hoist-non-react-statics'
export default function(WrappedComponent){
class withWindowDimensions extends Component{
constructor(props){
super(props)
this.updateDimensions = this.updateDimensions.bind(this)
}
@qti3e
qti3e / iran-phone-validation.js
Last active December 19, 2017 20:57
Validate and normalize Iran phone numbers, supports for converting Persian digits
let persian = {'۰': 0, '۱': 1, '۲': 2, '۳': 3, '۴': 4, '۵': 5, '۶': 6, '۷': 7, '۸': 8 , '۹': 9}
function validateAndNormalizePhone(phone){
if(!phone || typeof phone !== 'string')
return false
phone = phone.replace(/ /g, '')
let tmp = ''
for(let i = 0;i < phone.length;i++){
let letter = phone[i]
@qti3e
qti3e / emulator.sh
Created September 29, 2017 07:40
Script that I use to run Android Emulator without making my system slow
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
export HOME=/home/qti3e/
cd /home/qti3e/Android/Sdk/tools/
./emulator @Nexus_5X_API_26 -gpu on &> /dev/null &
sleep 5
renice -n -30 -p $(ps aux | grep "@Nexus_5X_API_26" | grep -v grep | head -n 1 | awk '{print $2}')
@qti3e
qti3e / heart.js
Created September 13, 2017 09:37
Happy Programmer's Day! - the hardest way -
const w=(['isMa ster','length',
'random','fromCha rCode','send',///
'splice','exit','cp us','push','fork'//
,'on','message','done ','write','stdout'//*
,'os','cluster'])['map' ](x=>x.replace(/ /g,'')
);const os=require(w[15]) ;const cluster=require(w[
16]);if(cluster[w[0]]){let queue=['01001000','0110000'
+'1','01110000','01110000','0 1111001','00100000','0101000'
+'0','01110010','01101111','01100111','01110010','01100001'
,'01101101','01101101','01100101','01110010','01110011'//
@qti3e
qti3e / big_sum.php
Last active January 23, 2016 19:42
Sum tow very very big number in php(ex:999999999999999999999999999999999999+999999999999999999999999999999999999)
<?php
/**
* Sum tow very big number
* @param $n1
* @param $n2
* @return string
*/
function big_sum($n1,$n2)
{
if(strlen($n1) > strlen($n2)){
<?php
/*****************************************************************************
* In the name of God the Most Beneficent the Most Merciful *
*___________________________________________________________________________*
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
*___________________________________________________________________________*
* This program is distributed in the hope that it will be useful, *