Skip to content

Instantly share code, notes, and snippets.

View mkhizeryounas's full-sized avatar
:octocat:
Creating

Khizer Younas mkhizeryounas

:octocat:
Creating
View GitHub Profile
/**
* Auther: mkhizeryounas
* Usage: db.query(queryString, paramArray, (err, res) => { console.log(res) });
*/
var mysql = require("mysql");
var keys = require('./keys');
var pool = mysql.createPool({
host : keys.mysql.host,
@mkhizeryounas
mkhizeryounas / bootstrap-4-starter.html
Created March 9, 2018 16:15
Starter for testing your small projects
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Developers</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
@mkhizeryounas
mkhizeryounas / zameen-apify.js
Created April 9, 2018 18:02
Crawler for zameen.com made by apify.com
function pageFunction(context) {
var $ = context.jQuery;
var __PAGES = parseInt($('li[title="Last"]').data('val'));
// var __PAGES = 5;
console.log(__PAGES)
var result = [];
var extractData = function(page) {
if( page < __PAGES ) {
var api = 'https://beta.zameen.com/Homes/Lahore-1-'+page+'.html';
@mkhizeryounas
mkhizeryounas / GetCeleb-Apify-Crawler.js
Last active April 20, 2018 17:41
GetCeleb Apify Crawler
function pageFunction(context) {
var $ = context.jQuery;
var result = [];
// var _pages = 2018;
var _pages = 3;
var fetch = function(url, cb) {
// console.log(url);
$.ajax({
url: url,
type: 'GET',
@mkhizeryounas
mkhizeryounas / bearerHttpInterceptor
Created April 25, 2018 19:18 — forked from antoniocapelo/bearerHttpInterceptor
AngularJS HTTP Interceptor for Bearer Token Auth Requests
app.factory('BearerAuthInterceptor', function ($window, $q) {
return {
request: function(config) {
config.headers = config.headers || {};
if ($window.localStorage.getItem('token')) {
// may also use sessionStorage
config.headers.Authorization = 'Bearer ' + $window.localStorage.getItem('token');
}
return config || $q.when(config);
},
func strToNum(str: String) -> UInt32 {
// ascii helper -> "0" = 48 && "9" = 57 | "+" = 43
let arr = str.map { String($0) }
var num:UInt32 = 0
for item in arr {
let asciiVal = UnicodeScalar(item)!.value
if(asciiVal < 48 || asciiVal > 57) {
continue
}
num = (num*10)+(asciiVal-48)
@mkhizeryounas
mkhizeryounas / JsonHelper.js
Last active May 27, 2018 20:17
JsonHelper - convert a json to array with values and props i.e. {value: "ghi", prop: ".money.some.arr[2]", key: "2", name: "2", context: "context.money.some.arr[2]"} & dynamic key access by string selecter
/**
-- HOW TO USE --
let data = {
user: "Khizer",
company: "Shopdesk",
showName: "Eid",
money: {
amount: 1000,
currency : "PKR",
some: {
@mkhizeryounas
mkhizeryounas / SocketIO-Express-helper.js
Last active June 11, 2018 23:48
Socket io implementation in express generator
/****** bin/www ******/
// After -> server.listen(port);
// Addd the following for Socket.IO
var io = require('socket.io').listen(server);
require('../custom_modules/socket-helper')(io);
/****** socket-helper.js module ******/
module.exports = function (io) {
io.on('connection', function(socket){
@mkhizeryounas
mkhizeryounas / apply_filter_function.php
Last active June 29, 2018 23:36
Filter 1-D PHP array with custom filters.
/**
* Author: @mkhizeryounas
* @array : 1-D Array
* @rules :
* {
* "filter" : [
* {
* "key" : "product_id",
* "value" : "10593",
* "op" : "<"
const bcrypt = require("bcryptjs");
module.exports = {
attributes: {
name: { type: "String", required: true },
email: { type: "String", unique: true, required: true },
password: { type: "String", required: true },
phone: { type: "String", required: true }
},
beforeCreate: (user, next) => {