Skip to content

Instantly share code, notes, and snippets.

🏫
Final year of secondary school

Parsa Ghadimi qti3e

Block or report user

Report or block qti3e

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
@qti3e
qti3e / redis-indexer.flow.js
Last active Feb 24, 2018
Show-case: Redis as a simple indexing backend in Node.js
View redis-indexer.flow.js
// @flow
import Redis from 'redis';
import bluebird from 'bluebird';
import type {RedisClient} from 'redis';
import uuid from 'uuid/v4';
import md5 from 'md5';
bluebird.promisifyAll(Redis.RedisClient.prototype);
const SearchClient: RedisClient = Redis.createClient({
db: 2
});
@qti3e
qti3e / Perceptron.js
Last active Jan 31, 2018
Simple Perceptron in Propel
View Perceptron.js
import { Params, T } from "propel"
let params = new Params()
let trainingData = [
[[0, 0, 1], 0],
[[0, 1, 1], 1],
[[1, 0, 1], 1],
[[1, 1, 1], 1]
]
let unit_step = x => x < 0 ? 0 : 1
let w = params.randn("W", [3])
@qti3e
qti3e / withWindowDimensions.js
Created Jan 28, 2018
withWindowDimensions React.js HOC
View withWindowDimensions.js
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 Dec 19, 2017
Validate and normalize Iran phone numbers, supports for converting Persian digits
View iran-phone-validation.js
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 Sep 29, 2017
Script that I use to run Android Emulator without making my system slow
View emulator.sh
#!/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 Sep 13, 2017
Happy Programmer's Day! - the hardest way -
View heart.js
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 / README.md
Last active May 5, 2019
List of file signatures and mime types based on file extensions
View README.md
@qti3e
qti3e / backend.min.js
Created Apr 11, 2017
js_composer backend.min.js debugged version
View backend.min.js
function setCookie(e,t,i){var n=new Date;n.setDate(n.getDate()+i);var a=encodeURIComponent(t)+(null===i?"":"; expires="+n.toUTCString());document.cookie=e+"="+a}function getCookie(e){var t,i,n,a=document.cookie.split(";");for(t=0;t<a.length;t++)if(i=a[t].substr(0,a[t].indexOf("=")),n=a[t].substr(a[t].indexOf("=")+1),i=i.replace(/^\s+|\s+$/g,""),i==e)return decodeURIComponent(n)}function vc_toTitleCase(e){return e.replace(/\w\S*/g,function(e){return e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()})}function vc_convert_column_size(e){var t="vc_col-sm-",i=e?e.split("/"):[1,1],n=_.range(1,13),a=_.isUndefined(i[0])||0>_.indexOf(n,parseInt(i[0],10))?!1:parseInt(i[0],10),s=_.isUndefined(i[1])||0>_.indexOf(n,parseInt(i[1],10))?!1:parseInt(i[1],10);return!1!==a&&!1!==s?t+12*a/s:t+"12"}function vc_convert_column_span_size(e){return e=e.replace(/^vc_/,""),"span12"===e?"1/1":"span11"===e?"11/12":"span10"===e?"5/6":"span9"===e?"3/4":"span8"===e?"2/3":"span7"===e?"7/12":"span6"===e?"1/2":"span5"===e?"5/12":"span4"===e?
View multiplication.php
<?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, *
@qti3e
qti3e / big_sum.php
Last active Jan 23, 2016
Sum tow very very big number in php(ex:999999999999999999999999999999999999+999999999999999999999999999999999999)
View big_sum.php
<?php
/**
* Sum tow very big number
* @param $n1
* @param $n2
* @return string
*/
function big_sum($n1,$n2)
{
if(strlen($n1) > strlen($n2)){
You can’t perform that action at this time.