Skip to content

Instantly share code, notes, and snippets.

{
"AEAJM": {
"name": "Ajman",
"city": "Ajman",
"country": "United Arab Emirates",
"alias": [],
"regions": [],
"coordinates": [
55.5136433,
25.4052165
@shcyiza
shcyiza / Startup.cs
Last active January 23, 2020 18:16
access env var in dotnet core
public Startup(IConfiguration configuration)
{
Configuration = configuration;
StaticConfig = configuration;
}
public static IConfiguration Env { get; private set; }
// to use simply call the static member from anywher in the app
// Startup.Env["Jwt:issuer"]
@shcyiza
shcyiza / ssccee_where_statement_with_included_model.js
Last active November 5, 2019 13:49
SSCCE paginate where statement with included model issue
'use strict';
module.exports = async function(createSequelizeInstance, log) {
const { Sequelize, Op, Model, DataTypes } = require('sequelize');
const sequelize = createSequelizeInstance({ benchmark: true });
await sequelize.authenticate();
const Report = sequelize.define('Report', {
name: DataTypes.STRING,
@shcyiza
shcyiza / car_brands.json
Created September 2, 2019 21:30
list of car brands name and logo in JSON format
[
{
"logo": "https://www.car-logos.org/wp-content/uploads/2011/09/abarth1.png",
"name": "Abarth"
},
{
"logo": "https://www.car-logos.org/wp-content/uploads/2011/09/ac-cars.png",
"name": "AC"
},
{
{
"data": {
"GetTodosAsAssignee": [
{
"id": 7,
"report_id": 64,
"text": "do the dishes",
"status": "awaiting",
"assignee": [
@shcyiza
shcyiza / auth2_services.js
Last active May 26, 2022 08:36
showing off how to dynamically invoke function in JS
const OAUTH2_OPTIONS = {
facebookLogin() {
// do the oath2 procedure for FB
},
googleLogin() {
// do the oath2 procedure for google
},
instagramLogin() {
// do the oath2 procedure for instagram
}
// respond variable was given before
function displayContent(attrName, lang) {
const valid_attrs = ["title", "abstract"]
const valid_langs = ["en", "nl", "fr"]
// validate attrName and lang before accessing property
if (valid_attrs.includes(attrName) && valid_langs.includes(lang)) return respond.data[attrName][lang]
return null
}
{
"status": 200,
"data":{
"title": {
"en": "How many hot-dogs can you eat?",
"nl": "Hoevel hot-dogs kunt gij eten?",
"fr": "Combien de hot-dogs peux-tu manger?",
},
"abstract": {
"en": "Deep dive into the dark world of hot-dog eaters contest...",
@shcyiza
shcyiza / inheritance.js
Last active May 28, 2019 07:19
shallow and deep clone objects with inheritance
// shallow copy
function cloneWithProto (source, target = {}) {
// if you just want to copy the source the target is optional
let clone = {...source, ...target}
// make shallow copy out of source, and overwrite with target
Object.setPrototypeOf(clone, Object.getPrototypeOf(source))
// set the proto of result to the proto of source object
return clone
import { SET_BOOKNAME, ADD_BOOKMARK, DELETE_BOOKMARK } from '../actions/types';
export default function bookmarksReducer(state = {book_name: "", list: []}, action) {
switch (action.type) {
case SET_BOOKNAME:
return {...state, book_name: action.payload}
// copy the current state
// and change the value of book_name property
// with payload property given by the action
case ADD_BOOKMARK: