Skip to content

Instantly share code, notes, and snippets.

View irfanbaigse's full-sized avatar
:bowtie:
PHP - Node.js - JAVA - AWS - Flutter - MT5/MT4

Irfan Baig irfanbaigse

:bowtie:
PHP - Node.js - JAVA - AWS - Flutter - MT5/MT4
View GitHub Profile
@irfanbaigse
irfanbaigse / client.js
Created March 19, 2019 13:21 — forked from davidgilbertson/client.js
Node http vs net modules
// This makes two connections, one to a tcp server, one to an http server (both in server.js)
// It fires off a bunch of connections and times the response
// Both send strings.
const net = require(`net`);
const http = require(`http`);
function parseIncomingMessage(res) {
return new Promise((resolve) => {
@irfanbaigse
irfanbaigse / express-500-error-handling.js
Created September 29, 2019 11:14
Express 500 error handling
const app = express();
// define your custom routes here
app.use('/test', (req, res) => {
res.status(200).json({ message: 'your test route' });
);
// 500 - Any server error - at the end
app.use((err, req, res, next) => {
return res.status(500).json({ error: err.toString() });
@irfanbaigse
irfanbaigse / example.php
Created October 22, 2019 19:54
Singly Linked List
<?php
use DataStructures\LinkedList;
$linkedList = new LinkedList();
$linkedList->inserFirst(10);
$linkedList->inserFirst(20);
$linkedList->insertLast(40);
$linkedList->insertLast(30);
@irfanbaigse
irfanbaigse / Common-Currency.json
Created January 2, 2020 08:25 — forked from ksafranski/Common-Currency.json
Common Currency Codes in JSON
{
"USD": {
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
},
@irfanbaigse
irfanbaigse / random-int-max-min-in-javascript.js
Created January 21, 2020 13:27
generate random int between range in javascript or nodejs or js
function getRandomInt(lower, upper) {
return Math.floor(Math.random() * (upper - lower + 1)) + lower;
}
console.log(getRandomInt(1,100));
// expected output: a number between 1 and 100
console.log(Math.random());
// expected output: a number between 0 and 1
class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def display(self):
@irfanbaigse
irfanbaigse / README.md
Created August 30, 2021 20:09 — forked from ngryman/README.md
intellij javascript live templates

intellij javascript live templates

Just a dump of handy live templates I use with IntelliJ. They should also work with WebStorm.

How to

  • Go to settings.
  • Search for live templates.
  • Under the javascript section you should be able to manage your templates.
@irfanbaigse
irfanbaigse / install.sh
Created January 11, 2022 12:40 — forked from aaabramov/install.sh
Installing zsh + oh-my-zsh on Amazon EC2 Amazon Linux 2 AMI. (Prepared in the scope of posting https://aaabramov.medium.com/installing-zsh-oh-my-zsh-on-amazon-ec2-amazon-linux-2-ami-88b5fc83109)
sudo yum update
# Installing ZSH
sudo yum -y install zsh
# Check ZSH has been installed
zsh --version
# Install "util-linux-user" because "chsh" is not available by default
# See https://superuser.com/a/1389273/599050
@irfanbaigse
irfanbaigse / local-valet-drvier.php
Created January 13, 2022 06:22
Local Laravel / Lumen Valet Driver
<?php
// paste this file in root folder of your project
// and run command "valet link ."
class LocalValetDriver extends LaravelValetDriver
{
/**
* Determine if the driver serves the request.
*
@irfanbaigse
irfanbaigse / ext-xdebug.ini
Created January 13, 2022 06:35
php xdebug config for phpstorm mac
# subl /usr/local/etc/php/7.3/conf.d/ext-xdebug.ini
[xdebug]
xdebug.mode = debug
xdebug.max_nesting_level = 1000
xdebug.start_with_request=yes
xdebug.client_port=9090
xdebug.client_host=127.0.0.1
xdebug.discover_client_host=1
xdebug.idekey=PHPSTORM