Skip to content

Instantly share code, notes, and snippets.

View KhaledElAnsari's full-sized avatar
🙄

Khaled Al-Ansari KhaledElAnsari

🙄
View GitHub Profile
@KhaledElAnsari
KhaledElAnsari / android_instructions.md
Created July 10, 2017 06:51 — forked from patrickhammond/android_instructions.md
Easily setup an Android development environment on a Mac

Here is a high level overview for what you need to do to get most of an Android environment setup and maintained.

Prerequisites (for Homebrew at a minimum, lots of other tools need these too):

  • XCode is installed (via the App Store)
  • XCode command line tools are installed (xcode-select --install will prompt up a dialog)
  • Java

Install Homebrew:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

@KhaledElAnsari
KhaledElAnsari / README.md
Created March 27, 2017 15:38 — forked from krimple/README.md
Test and class under test for Http mocking - Angular 2 beta 1

This snippet is a working example of a test against the Http service in Angular 2.0.

It is a very simple test, and provides an example of how to:

  • Provide the right wiring to the test injector
  • Inject the fake XHRBackend (i.e. MockBackend)
  • Define a potential request
  • Run the request in the framework
  • Set expectations on the result
@KhaledElAnsari
KhaledElAnsari / match_arabic_hmaz_letter.js
Last active March 23, 2017 19:28 — forked from msalahat/match_arabic_hmaz_letter.js
Match user search with hamza in Arabic ( أ، ا ، آ ، إ ) against a list of words - UTF8
let match_arabic = (user_input, word) => {
let user_input_regx = "";
// البحث عن أ، ا ، آ و إ
let hamz_letters = ["أ", "ا", "آ", "إ"].join("|")
const hamz_regx = new RegExp(hamz_letters);
for (let d = 0, len = user_input.length; d < len; d++) {
user_input_regx += ( hamz_regx.test(user_input.charAt(d)) ? "[" + hamz_letters + "]" : user_input.charAt(d) );
}
@KhaledElAnsari
KhaledElAnsari / detect-private-browsing.js
Created March 12, 2017 12:47 — forked from cou929/detect-private-browsing.js
Detect private browsing mode (InPrivate Browsing or Incognito).
function retry(isDone, next) {
var current_trial = 0, max_retry = 50, interval = 10, is_timeout = false;
var id = window.setInterval(
function() {
if (isDone()) {
window.clearInterval(id);
next(is_timeout);
}
if (current_trial++ > max_retry) {
window.clearInterval(id);
@KhaledElAnsari
KhaledElAnsari / router.html
Created June 13, 2016 22:10 — forked from joakimbeng/router.html
A really simple Javascript router
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Building a router</title>
<script>
// Put John's template engine code here...
(function () {
// A hash to store our routes: