Skip to content

Instantly share code, notes, and snippets.

View ilyaskarim's full-sized avatar

Ilyas Karim ilyaskarim

View GitHub Profile
@ilyaskarim
ilyaskarim / code.md
Last active December 3, 2022 12:48
Ai generated code

/* I need a function which checks if a string is a pakistani phone number */

function isPakistaniPhoneNumber(phoneNumber) {
  var phoneNumberRegex = /^\+92[0-9]{10}$/;
  return phoneNumberRegex.test(phoneNumber);
}

/* /* I need a function which checks if a string is a indian phone number */ */

function isIndianPhoneNumber(phoneNumber) {
@ilyaskarim
ilyaskarim / limit-speed.js
Created November 19, 2020 21:31
limit-speed
var allSpeeds = document.querySelectorAll(".bEptLHDSpeeds");
var limits = document.querySelectorAll(".bEptLHDDownLimit");
allSpeeds.forEach((element, index) => {
element.setAttribute(`idx`, index);
});
limits.forEach((element, index) => {
element.setAttribute(`computer-${index}-limit`, null);
});
@ilyaskarim
ilyaskarim / Wertik - Custom Module - Rest API Endpoints.ts
Created April 5, 2020 20:10
Wertik - Custom Module - Rest API Endpoints
let configuration = {
// other configuration
modules: [
{
name: "Person",
restApi: {
endpoints: [
{
path: "/path",
methodType: "post",
@ilyaskarim
ilyaskarim / Wertik-js custom module - GraphQL.ts
Created April 5, 2020 19:29
Wertik-js custom module - GraphQL
let configuration = {
modules: [
{
// other module configuration
graphql: {
crud: {
query: {
generate: true,
operations: "*", // Options are view, list
},
@ilyaskarim
ilyaskarim / Wertik Custom Modules - Database options.ts
Last active April 5, 2020 19:14
Wertik Custom Modules - Database options
let configuration = {
modules: [
{
useDatabase: true, // Set false if you are not storing data for this module.
database: {
sql: {
tableName: "YOUR_TABLE_NAME",
tableOptions: {
// Use Sequelize table options here, Please see https://sequelize.org/v5/manual/models-definition.html
// See section: Apart from datatypes, there are plenty of options that you can set on each column.
@ilyaskarim
ilyaskarim / wertik-js-configuration-custom-module.ts
Last active April 5, 2020 15:45
wertik-js-configuration-custom-module
let otherConfiguration = {}; // Here other wertik configuration
let configuration = {
...otherConfiguration,
modules: [
{
name: "Article",
useDatabase: true,
fields: {
sql: {
title: {
@ilyaskarim
ilyaskarim / wertik-PostgreSQL-database-connec.ts
Created April 5, 2020 14:00
wertik-PostgreSQL-database-connec.ts
import defaultConfiguration from "./defaultConfiguration";
let configuration = { ...defaultConfiguration };
configuration.database = {
dbDialect: "postgres",
dbUsername: "wmysixugpufzba",
dbPassword: "7255d55e83deafe26d093306e958b7e50dad5ac02f687249d02c9a53590c120f",
dbName: "d5rsarnju68s4f",
dbHost: "ec2-54-246-89-234.eu-west-1.compute.amazonaws.com",
@ilyaskarim
ilyaskarim / wertik-js-mysql-database-connect.ts
Created April 5, 2020 13:56
wertik-js-mysql-database-connect.ts
export default {
name: "Wertik",
// ... Rest of the configuration
database: {
dbDialect: "mysql",
dbUsername: "root",
dbPassword: "pass",
dbName: "graphql",
dbHost: "localhost",
dbPort: "3306"
@ilyaskarim
ilyaskarim / Context-in-Rest-API.ts
Created April 5, 2020 12:59
Context in Rest API
// Consider below function as Expess JS Rest Api Handler
function (req,res) {
// context is available in req.[context_name] and configuration passed context is available at req.context
}
@ilyaskarim
ilyaskarim / context-in-graphql.ts
Created April 5, 2020 12:56
context-in-graphql.ts
// Consider below function as GraphQL resolver.
function (_, args, context,info) {
// You can access wertik context through context.[context_name], including configuration passed context.
}