Skip to content

Instantly share code, notes, and snippets.

View alash3al's full-sized avatar

Mohammed Al Ashaal alash3al

View GitHub Profile
@alash3al
alash3al / timeDiff2.js
Created January 6, 2016 20:59
Implementation of the "since x time ago" format, it starts from second to millennium ;-)
/*
* timeDiff, return the difference between two times "in seconds"
* in the format of "since x (second|minute|...)(s) ago" .
*
* @version v2.0
* @license MIT License
* @author Mohammed Al Ashaal <www.alash3al.xyz>
* @example `console.log(timeDiff(current_unix_timestamp, old_unix_timestamp))`
* @return Object
*/
@alash3al
alash3al / google_speech2text.md
Created February 28, 2016 20:57 — forked from alotaiba/google_speech2text.md
Google Speech To Text API

Google Speech To Text API

Base URL: https://www.google.com/speech-api/v1/recognize
It accepts POST requests with voice file encoded in FLAC format, and query parameters for control.

Query Parameters

client
The client's name you're connecting from. For spoofing purposes, let's use chromium

lang
Speech language, for example, ar-QA for Qatari Arabic, or en-US for U.S. English

@alash3al
alash3al / xerver.php
Created March 3, 2016 12:22
dirty & quick php router only for xerver platform
<?php namespace xerver;
// sort the _SERVER array based on its keys
ksort($_SERVER);
// normalize our path-info
$_SERVER["PATH_INFO"] = preg_replace("~/+~", "/", "/" . $_SERVER["PATH_INFO"] . "/");
// start the output buffer
ob_start();
@alash3al
alash3al / mksite.sh
Last active May 7, 2016 08:28
nginx+php environment
#!/bin/sh
# change this to the apps directory
apps_dir=/home/alash3al/Dev/php
# don't change this var's value
site=$1
# just change
htdocs=$apps_dir/$site
<?php
/**
* Horus "Core" - be simple :)
*
* This version will only work on PHP 7 and higher .
*
* @package Horus
* @copyright 2014 - 2016 (c) Horus
* @author Mohammed Al Ashaal <alash3al.xyz>
* @license MIT LICENSE
/**
* Get the difference between two dates in detailed info
*
* @param float|int d1
* @param float|int d2
*
* @return Object
*/
function timeDiffBetween(d1, d2) {
result = {
@alash3al
alash3al / gist:b4a93e5f20622bf6655541f03ea78501
Created January 26, 2017 10:04 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

<?php
/**
* Convert the specified minutes (int) to the specified format (hours)
*
* @author Mohammed Al Ashaal <https://alash3al.xyz>
* @version 1.0
* @return string
*/
function minutes2hours($m, $format = "%02d:%02d") {
if ( $m < 60 ) {
@alash3al
alash3al / gist:4671c476823f97b4d1f664d5a236236e
Created October 18, 2017 08:40 — forked from piotrekkaminski/gist:9bc45ec84028611d621e
How to automatically download patches and release of Magento
1) First you need to generate download token. Login to your account on magento.com and generate it in Account Settings->Downloads Access Token
2) You will need your MAGEID as well. It is shown at the top-left in your account page.
3) curl -k https://MAGEID:[email protected]/products/downloads/info/help
4) Profit!
@alash3al
alash3al / Magento2.md
Created October 23, 2017 12:33 — forked from JeansBolong/Magento2.md
Magento2 CheatSheet

Magento 2 tutorial

http://devdocs.magento.com/guides/v2.1/frontend-dev-guide/bk-frontend-dev-guide.html
https://www.creare.co.uk/blog/magento/theming-in-magento-2-part-1
https://www.creare.co.uk/blog/magento/theming-in-magento-2-part-2
http://alanstorm.com/category/magento-2/

I have installed Magento 2 successfully, but icons are not displaying and not able to click anywhere in backend.

Please try running following command.