Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Alfred Francis alfredfrancis

🏠
Working from home
View GitHub Profile
@alfredfrancis
alfredfrancis / sessionStore.ts
Created Jul 6, 2017
Angular 4 - Persist & retrive variables over session
View sessionStore.ts
persist(key,value){
/*
* Store user information in sessionStorage
* @param {string} key - key name
* @param {json} value - value
* @return {}
*/
if(typeof value == "object"){
return sessionStorage.setItem(key,JSON.stringify(value))
}else{
@alfredfrancis
alfredfrancis / countryDetails.json
Created Jun 22, 2017
Country details including => Country code, Country Name, Currency code ,Currency Name and Dial Code
View countryDetails.json
[{"cCode": "IL", "dialCode": "+972", "cName": "Israel", "ccyName": "New Israeli Sheqel", "ccyCode": "ILS"}, {"cCode": "AF", "dialCode": "+93", "cName": "Afghanistan", "ccyName": "Afghani", "ccyCode": "AFN"}, {"cCode": "AL", "dialCode": "+355", "cName": "Albania", "ccyName": "Lek", "ccyCode": "ALL"}, {"cCode": "DZ", "dialCode": "+213", "cName": "Algeria", "ccyName": "Algerian Dinar", "ccyCode": "DZD"}, {"cCode": "AS", "dialCode": "+1 684", "cName": "AmericanSamoa", "ccyName": "US Dollar", "ccyCode": "USD"}, {"cCode": "AD", "dialCode": "+376", "cName": "Andorra", "ccyName": "Euro", "ccyCode": "EUR"}, {"cCode": "AO", "dialCode": "+244", "cName": "Angola", "ccyName": "Kwanza", "ccyCode": "AOA"}, {"cCode": "AI", "dialCode": "+1 264", "cName": "Anguilla", "ccyName": "East Caribbean Dollar", "ccyCode": "XCD"}, {"cCode": "AG", "dialCode": "+1268", "cName": "Antigua and Barbuda", "ccyName": "East Caribbean Dollar", "ccyCode": "XCD"}, {"cCode": "AR", "dialCode": "+54", "cName": "Argentina", "ccyName": "Argentine Peso",
View feedback.ts
postFeedback(feedback){
return new Promise(
(resolve,reject)=>{
let headers = new Headers(
{
'Content-Type': 'application/json'
}
)
let options = new RequestOptions(
{
@alfredfrancis
alfredfrancis / CommonUtilsProvider.ts
Created Jun 12, 2017
Common utilities for Angular 4/ionic3
View CommonUtilsProvider.ts
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import * as CryptoJS from 'crypto-js';
import {CommonVariablesProvider} from '../common-variables/common-variables'
import { ToastController, Toast } from 'ionic-angular';
import { AlertController, Alert } from 'ionic-angular';
/*
* Common Utilities provider
@alfredfrancis
alfredfrancis / CommonServiceProvider.ts
Created Jun 12, 2017
Common http provider for Angular 4
View CommonServiceProvider.ts
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import { CommonUtilsProvider } from '../../providers/common-utils/common-utils';
import { CommonVariablesProvider } from '../../providers/common-variables/common-variables'
/*
* Common Services Provider
* @author Alfred Francis
* @date 10/06/2017
*/
@alfredfrancis
alfredfrancis / index.html
Created May 31, 2017 — forked from adunkman/index.html
Relay messages from RabbitMQ to a browser using Socket.io
View index.html
<!DOCTYPE html>
<html>
<head>
<script src="/socket.io/socket.io.js"></script>
<script>
(function () {
var onMessage = function (data) {
// Do something with the message data
};
@alfredfrancis
alfredfrancis / jquery_insert_solr.html
Created May 20, 2017
Use jquery to insert and commit json document to solr
View jquery_insert_solr.html
<!DOCTYPE html>
<svg width="960" height="500"></svg>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
var jsonData = JSON.stringify([{
"starttime": "2010-10-07T15:56:23.477Z",
"functionid": "476",
"userid": "roney"
}]);
@alfredfrancis
alfredfrancis / restheart_mongodb_fileupload.py
Created May 10, 2017
Upload files to MongoDB GridFS using Restheart API and Python
View restheart_mongodb_fileupload.py
import requests
# https://softinstigate.atlassian.net/wiki/pages/viewpage.action?pageId=11567174=
files = {
'file': open("helloworld.mp3", 'rb')
}
values={
'properties':'"filename":"helloworld.mp3"')
}
@alfredfrancis
alfredfrancis / example.py
Created Apr 21, 2017 — forked from mattupstate/example.py
JSON Patch SQLAlchemy models w/ Flask
View example.py
from dictalchemy import make_class_dictable
from flask import Flask, request, jsonify, json
from flask_sqlalchemy import SQLAlchemy
from jsonpatch import JsonPatch, JsonPatchException
app = Flask(__name__)
app.debug = True
db = SQLAlchemy(app)
make_class_dictable(db.Model)
@alfredfrancis
alfredfrancis / currency_code_vs_currency_name.json
Created Apr 20, 2017
JSON of common currency codes vs Currency names
View currency_code_vs_currency_name.json
[
{
"currencycode": "Afghani",
"code": "AFN"
},
{
"currencycode": "Euro",
"code": "EUR"
},
{