Skip to content

Instantly share code, notes, and snippets.

View surferxo3's full-sized avatar

Mohammad Sharaf Ali surferxo3

View GitHub Profile
@surferxo3
surferxo3 / rect_draw.html
Last active July 26, 2020 12:12
Movable and re-sizable rectangle using Raphael SVG
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Movable and Re-sizable Raphael JS Shape</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0/css/bootstrap.min.css">
</head>
<body>
@surferxo3
surferxo3 / lodash.ts
Created March 2, 2018 12:39
Counting elements in array of objects using Lodash
// without lodash
let currentGradeId;
let looper = 0;
let tempArray = {};
let finalArray = [];
this.items.forEach((obj, index) => {
currentGradeId = this.items[index].grade_id;
if (tempArray[currentGradeId] === undefined) {
@surferxo3
surferxo3 / shared.module.ts
Last active April 15, 2018 19:13
Get all validation errors from Angular 2+ FormArray and FormGroup in human readable form
import {NgModule, Injectable} from '@angular/core';
import {AbstractControl, FormArray, FormControl, FormGroup, ValidationErrors} from '@angular/forms';
import {mapValues, filter, isArray, isEmpty, isPlainObject, keys, findKey} from 'lodash';
@NgModule({
imports: [],
declarations: [],
exports: [],
providers: [],
})
@surferxo3
surferxo3 / late_static_bindings.php
Last active July 26, 2020 12:10
Understanding difference between __CLASS__, get_class(), and get_called_class() with underlying self/static keyword
<?php
/*#############################
* Developer: Mohammad Sharaf Ali
* Designation: Web Developer
* Version: 1.0
*/#############################
class c1
{
@surferxo3
surferxo3 / config.php
Last active February 5, 2018 15:23
Silex guzzle provider implementation using handler stack consisting of mapRequest, retry, and log middleware
<?php
/*#############################
* Developer: Mohammad Sharaf Ali
* Designation: Web Developer
* Version: 1.0
*/#############################
$handler = new CurlHandler();
$stack = HandlerStack::create($handler);\
@surferxo3
surferxo3 / auto_connect.js
Last active July 26, 2020 12:10
LinkedIn 'People you may know' auto connect script
/*
* just copy and paste the script inside the console and hit enter
* {"status":429} response is returned when api rate limit exceeds
*/
jQuery('button[data-control-name="invite"]').each(function(index, value) {
setTimeout(function() {
jQuery(value).trigger('click');
}, index * 1000);
});
@surferxo3
surferxo3 / gateways.php
Last active November 14, 2017 12:44
Script to fetch Merchant Gateways from Konnektive Crm. Demonstrates data automation and scrapping from a specific source.
<?php
/*#############################
* Developer: Mohammad Sharaf Ali
* Designation: Web Developer
* Version: 1.0
*/#############################
ini_set('max_execution_time', 0);
ini_set('memory_limit', '1G');
@surferxo3
surferxo3 / model.php
Last active November 13, 2017 17:17
Code to handle File Input Validation inside Model in Yii2 Multiple Input widget
<?php
/*#############################
* Developer: Mohammad Sharaf Ali
* Designation: Web Developer
* Version: 1.0
*/#############################
/* REQUIREMENTS
* https://github.com/unclead/yii2-multiple-input
@surferxo3
surferxo3 / pdf.php
Last active September 29, 2017 17:04
Script to replace Placeholders with Values in Editable Form in PDF
<?php
/*#############################
* Developer: Mohammad Sharaf Ali
* Designation: Web Developer
* Version: 1.0
*/#############################
/* REQUIREMENTS
* https://www.pdflabs.com/tools/pdftk-server/
@surferxo3
surferxo3 / logging.php
Last active April 28, 2017 12:17
Runtime message output for error logging and monitoring with support for different OS platforms.
<?php
/*#############################
* Developer: Mohammad Sharaf Ali
* Designation: Web Developer
* Version: 1.0
*/#############################
// HELPER METHODS
function br2nl($str) {