Skip to content

Instantly share code, notes, and snippets.

View ali-master's full-sized avatar
🎯
Focusing on Something new!

Ali Torki ali-master

🎯
Focusing on Something new!
View GitHub Profile
function get_avatar_from_service(service, userid, size) {
// this return the url that redirects to the according user image/avatar/profile picture
// implemented services: google profiles, facebook, gravatar, twitter, tumblr, default fallback
// for google use get_avatar_from_service('google', profile-name or user-id , size-in-px )
// for facebook use get_avatar_from_service('facebook', vanity url or user-id , size-in-px or size-as-word )
// for gravatar use get_avatar_from_service('gravatar', md5 hash email@adress, size-in-px )
// for twitter use get_avatar_from_service('twitter', username, size-in-px or size-as-word )
// for tumblr use get_avatar_from_service('tumblr', blog-url, size-in-px )
// everything else will go to the fallback
// google and gravatar scale the avatar to any site, others will guided to the next best version
@ali-master
ali-master / LunchTelegtam.md
Last active December 27, 2016 00:06
Lunch telegram link with installed Telegram application

Lunch telegram link with installed Telegram application

var protoUrl = "tg:\/\/resolve?domain=TelegramUserName";
if (false) {
    var iframeContEl = document.getElementById('telegramIframe') || document.body;
    var iframeEl = document.createElement('iframe');
    iframeContEl.appendChild(iframeEl);
    var pageHidden = false;
 window.addEventListener('pagehide', function () {
@ali-master
ali-master / webpack.config.js
Last active May 30, 2018 01:38
A Sample Webpack config file
const path = require('path');
const webpack = require('webpack');
const config = {
entry: "./app/app.js",
output: {
filename: 'app.min.js',
path: './public/static/'
},
devtool: "eval-source-map",
@ali-master
ali-master / bitcolor.js
Created September 30, 2016 20:26 — forked from lrvick/bitcolor.js
Javascript functions for doing fast binary/hex/RGB color conversions using bitwise operations.
// convert 0..255 R,G,B values to binary string
RGBToBin = function(r,g,b){
var bin = r << 16 | g << 8 | b;
return (function(h){
return new Array(25-h.length).join("0")+h
})(bin.toString(2))
}
// convert 0..255 R,G,B values to a hexidecimal color string
RGBToHex = function(r,g,b){
@ali-master
ali-master / Export Function
Created October 1, 2016 10:19
Export Function in AMD And CommonJS
(function(global, factory) {
/*global define: false*/
/*global exports: true*/
if (typeof exports === 'object' && exports) {
factory(exports); // CommonJS
} else if (typeof define === 'function' && define.amd) {
define(['exports'], factory); // AMD
} else {
factory(global); // <script>
@ali-master
ali-master / QueryToJSON
Last active October 7, 2016 14:08
Convert Query to JSON
// <refrence path="https://jsfiddle.net/dm1ufzz3/" />
function QueryStringToJSON(str) {
var pairs = str.split('&');
var result = {};
pairs.forEach(function (pair) {
pair = pair.split('=');
var name = pair[0]
var value = pair[1]
if (name.length)
@ali-master
ali-master / README.md
Last active August 22, 2017 20:08
چک کردن درستی کد ملی ایرانی | Check Iranian National Code Validity

Usage

var check = checkCodeMelli(4160476164); // return boolean
@ali-master
ali-master / webpack.config.js
Created December 6, 2016 10:04
Webpack Config
/**
* npm install --save-dev webpack babel-loader babel-core babel-preset-{es2015,react} style-loader css-loader sass-loader
* npm install --save react react-dom
* directory folders: static, public
*/
const path = require("path");
const webpack = require("webpack");
module.exports = {
@ali-master
ali-master / FullScreenAPI.md
Last active December 27, 2016 00:16
Javascript Full Screen API

Javascript fullScreen API

(function () {
    var fullScreenApi = {
        supportsFullScreen: false,
        nonNativeSupportsFullScreen: false,
        isFullScreen: function () { return false; },
        requestFullScreen: function () { },
        cancelFullScreen: function () { },