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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mkhizeryounas
mkhizeryounas / patari.sdk.js
Last active February 10, 2019 18:57
Bring patari songs to your own apps, lets you streams songs directly from patari.pk.
/**
* Developed by @mkhizeryounas
* How to use
* --- Example ---
const music = new Patari();
music.getHomeContent().then(res => {
music.playSong(res.songs[3].itemID);
// music.getSongInfo(res.songs[0].itemID).then(res2 => {
// console.log("getSongInfo", res2);
// });
@mkhizeryounas
mkhizeryounas / circular_primes.js
Last active December 1, 2018 18:02
List of all the circular primes under a million
function combs(num) {
let str = num.toString().split("");
let toRes = [];
var tmp = str;
for (i of str) {
let val = parseInt(tmp.join(""));
if (!toRes.includes(val)) toRes.push(val);
let t = tmp.shift();
tmp.push(t);
}
@mkhizeryounas
mkhizeryounas / node-api-standard-response.js
Last active November 27, 2018 21:03
NodeJS Response middleware for a standard response.
var HttpStatus = require("http-status-codes");
module.exports = function(req, res, next) {
res.result = responseJson => {
let data =
typeof responseJson.data === "undefined" ? {} : responseJson.data;
let statusCode =
typeof responseJson.statusCode === "undefined"
? 200
: responseJson.statusCode;
let message =
var disabledArr = ["01/08/2018"];
$("#kk").daterangepicker({
isInvalidDate: function(arg){
console.log(arg);
// Prepare the date comparision
var thisMonth = arg._d.getMonth()+1; // Months are 0 based
if (thisMonth<10){
@mkhizeryounas
mkhizeryounas / nested-json.js
Last active September 9, 2018 12:52
Get / Set of JSON via String
function set_mapping(key, value, obj) {
function mapper(keys, value, obj = {}) {
let keyName = keys.shift();
if (keys.length == 0) {
obj[keyName] = value;
} else {
obj[keyName] = mapper(keys, value, obj[keyName]);
}
return obj;
}
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) => {
@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" : "<"
@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 / 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: {