Skip to content

Instantly share code, notes, and snippets.

Avatar

Rabbi Shuki Gur rabbishuki

View GitHub Profile
View badError.js
sendToOtherNodeService = (url, bodyReq, timeout, callback) => {
try {
request({
url: url,
method: 'POST',
json: true,
body: bodyReq,
timeout: timeOut,
}, (error, response, body) => {
if (error != null) {
@rabbishuki
rabbishuki / login.js
Last active Jan 5, 2018
Login from admin as a different user.
View login.js
// If we have a token, try to login.
if (window.name) {
$.post("/login", {
token: window.name
});
}
/*
* The function to be called when clicking on a username from the Admin Panel.
* The second parameter of `window.open` is the new window's name.
@rabbishuki
rabbishuki / negativeNumberFilter.js
Last active Dec 31, 2017
An AngularJS filter to format negative numbers with the currency filter.
View negativeNumberFilter.js
app.filter('customCurrency', function ($filter) {
return function(amount, currencySymbol){
var currency = $filter('currency');
if(amount.charAt(0) === "-"){
return currency(amount, currencySymbol)
.replace("(", "-")
.replace(")", "");
}
@rabbishuki
rabbishuki / negativeNumberRunPhase.js
Last active Dec 31, 2017
An AngularJS Decorator to format negative numbers with the currency filter.
View negativeNumberRunPhase.js
angular.module('app')
.run(function ($locale) {
var currencyPatterns = $locale.NUMBER_FORMATS.PATTERNS[1];
patterns.negPre = '-\u00a4';
patterns.negSuf = '';
});
@rabbishuki
rabbishuki / negativeNumberConfigPhase.js
Last active Dec 31, 2017
An AngularJS Decorator to format negative numbers with the currency filter.
View negativeNumberConfigPhase.js
angular.module('app')
.config(function ($provide) {
$provide.decorator('$locale', function ($delegate) {
if ($delegate.id == 'en-us') {
$delegate.NUMBER_FORMATS.PATTERNS[1].negPre = '-\u00A4';
$delegate.NUMBER_FORMATS.PATTERNS[1].negSuf = '';
}
return $delegate;
});
});
View tsconfig.js
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"lib": [
"es2017"
]
},
"include": [
"src/**/*"
@rabbishuki
rabbishuki / DataFactory.js
Created Nov 21, 2017
Upload a file with angular 1.5
View DataFactory.js
// This service connects to our REST API
app.factory("Data", function ($http) {
var serviceBase = 'https://shekel.click/api/v1.2/';
var obj = {};
obj.file = function (q, file, fileName) {
var fd = new FormData();
fd.append('fileToUpload', file);
fd.append('fn', fileName);
fd.append('submit', 'ok');
@rabbishuki
rabbishuki / DataFactory.js
Created Nov 21, 2017
Upload a file with angular 1.5
View DataFactory.js
// This service connects to our REST API
app.factory("Data", function ($http) {
var serviceBase = 'https://shekel.click/api/v1.2/';
var obj = {};
obj.file = function (q, file, fileName) {
var fd = new FormData();
fd.append('fileToUpload', file);
fd.append('fn', fileName);
fd.append('submit', 'ok');