Skip to content

Instantly share code, notes, and snippets.

View sXakil's full-sized avatar
:octocat:
Working Remotely

Shakil Ahmmed sXakil

:octocat:
Working Remotely
View GitHub Profile
@sXakil
sXakil / PusherAuth.php
Last active June 20, 2022 10:08
Custom Pusher Auth for Private Channel
public function pusherAuth(Request $request) {
if(Auth::check()) {
$channel_name = $request->channel_name;
$socket_id = $request->socket_id;
$id = Auth::user()->id;
$auth_channel = 'private-chat-' . $id;
if($channel_name != $auth_channel) {
return response()->json('Forbidden', 403);
}
$data = $socket_id . ':' . $auth_channel;
function main(deem) {
"use strict";
var unicodeRegex =
/([\uD800-\uDBFF][\uDC00-\uDFFF](?:[\u200D\uFE0F][\uD800-\uDBFF][\uDC00-\uDFFF]){2,}|\uD83D\uDC69(?:\u200D(?:(?:\uD83D\uDC69\u200D)?\uD83D\uDC67|(?:\uD83D\uDC69\u200D)?\uD83D\uDC66)|\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D(?:\uD83D\uDC69\u200D)?\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D(?:\uD83D\uDC69\u200D)?\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]\uFE0F|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC6F\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3C-\u
@sXakil
sXakil / a_star.py
Created October 26, 2020 13:27
A* Implementation (Maze Solver)
from heapq import heappush, heappop
class PriorityQueue:
def __init__(self, iterable=[]):
self.heap = []
for value in iterable:
heappush(self.heap, (0, value))
def add(self, value, priority=0):
heappush(self.heap, (priority, value))
def pop(self):
@sXakil
sXakil / naive_bayes.py
Created October 26, 2020 13:26
Naive Bayes Classifier Implementation
testData = "Type Long NotLong Sweet NotSweet Yellow NotYellow Total\nBanana 400 100 350 150 450 50 500\nOrange 0 300 150 150 300 0 300\nOther 100 100 150 50 50 150 200\nTotal 500 500 650 350 800 200 1000"
file = open("data.txt", "w+")
file.write(testData)
file.close()
file = open("data.txt", "r")
lines = file.readlines()
file.close()
types = ['long', 'notlong', 'sweet', 'notsweet', 'yellow', 'notyellow', 'total']
@sXakil
sXakil / tic_tac_toe.py
Created October 26, 2020 13:25
Simple Tic Tac Toe
from random import randint
board = [
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
]
def eq(arr):
s = set(arr)
@sXakil
sXakil / bomber_simulation.py
Created October 26, 2020 13:24
Fighter-Bomber Simulation
const S = 30, reach = 30, timeout = 10;
let xb = [100, 110, 120, 130, 140, 149, 158, 168, 179, 188, 198, 209, 220],
yb = [0, 3, 6, 10, 15, 20, 26, 32, 37, 34, 30, 27, 23],
yf = [60],
xf = [0],
dist = [],
sinA = [],
cosA =[],
flag = false;
function run(time, intv = 1) {
@sXakil
sXakil / queue_system.py
Created October 26, 2020 13:22
Queue System Simulation
import random
a_mean = 10.0
a_sd = 1.5
s_mean = 9.5
s_sd = 1.0
lim = 15
NR1 = [0] * lim
NR2 = [0] * lim
IAT = [0] * lim
@sXakil
sXakil / chi_square_simulation.py
Created October 26, 2020 13:20
Chi-square Simulation
from random import randint
from math import ceil
N=100
lim=100 #int(input("enter total random number :"))
intrv = 10
random_number = [randint(1, lim) for i in range(0, N)]
from math import sqrt
from random import random
lim = 15 # int(input("Number of simulation: "))
radius = 1.0 # float(input("Enter the radius: "));
partition = 4 #{'full': 1, 'half': 2, 'quadrant': 4}[input("Enter the partition (full, half or quadrant): ")]
R1 = [round(random() * radius, 2) for i in range(0, lim)]
R2 = [round(random() * radius, 2) for i in range(0, lim)]
@sXakil
sXakil / debounce.js
Last active October 26, 2020 13:17
Basic debounce Function
function debounce(func, wait, immediate=false) {
var timeout;
return function() {
var context = this,
args = arguments;
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(function() {
timeout = null;
if (!immediate) {