Skip to content

Instantly share code, notes, and snippets.

View rahmathm1's full-sized avatar

Rahmathullah M rahmathm1

View GitHub Profile
@rahmathm1
rahmathm1 / template-function.js
Created June 20, 2017 09:58
Simple JavaScript template function
var template = function(html, options) {
var re = /<%([^%>]+)?%>/g, reExp = /(^( )?(if|for|else|switch|case|break|{|}))(.*)?/g, code = 'var r=[];\n', cursor = 0, match;
var add = function(line, js) {
js? (code += line.match(reExp) ? line + '\n' : 'r.push(' + line + ');\n') :
(code += line != '' ? 'r.push("' + line.replace(/"/g, '\\"') + '");\n' : '');
return add;
}
while(match = re.exec(html)) {
add(html.slice(cursor, match.index))(match[1], true);
cursor = match.index + match[0].length;
@rahmathm1
rahmathm1 / session-storage-ajax.js
Created February 14, 2017 13:59
A snippet that load data from Ajax once the store it in session storage, then use it from session storage for future calls.
/**
* load the content via AJAX,
* and attempt to cache in sessionStorage
*/
(function() {
var hasStorage = ("sessionStorage" in window && window.sessionStorage),
storageKey = "yourUniqueStorageKey",
now, expiration, data = false;
@rahmathm1
rahmathm1 / js-common.js
Created November 24, 2016 09:13
File that contains the main code
'use strict';
var HUB = HUB || {};
HUB.namespace = function (ns_string) {
...
return parent;
};
HUB.namespace('HUB.Portal');
@rahmathm1
rahmathm1 / jQuery-Pattern.js
Created November 24, 2016 07:33
JS-Pattern
HUB.namespace('HUB.Portal.Index');
HUB.Portal.Index = (function () {
'use strict';
var _self = {};
var resetSession = function (resetSessionUrl) {
...
}
@rahmathm1
rahmathm1 / AutoCopyTypeScript.csproj
Created February 10, 2015 10:57
MSBuild command for copying linked TypeScript files on build
<Project>
...
<Target Name="CopyLinkedTSFiles" BeforeTargets="Build">
<Copy SourceFiles="%(TypeScriptCompile.Identity)"
DestinationFiles="%(TypeScriptCompile.Link)"
SkipUnchangedFiles='true'
OverwriteReadOnlyFiles='true'
Condition="'%(TypeScriptCompile.Link)' != ''" />
</Target>
</Project>
@rahmathm1
rahmathm1 / cmd_build_corodova_release.txt
Created October 29, 2014 04:10
Build Cordova in release mode
platforms\android\cordova\build --release
@rahmathm1
rahmathm1 / Notification.java
Created October 28, 2014 13:59
Phonegap notification plugin edited to show progress spinner
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@rahmathm1
rahmathm1 / cmd_install_using_adb_cli.txt
Last active August 29, 2015 14:08
Install APK file to Android device using CLI
adb install -r platforms\android\ant-build\NammaCargo.apk