Skip to content

Instantly share code, notes, and snippets.

View fazlurr's full-sized avatar

Fazlur Rahman fazlurr

View GitHub Profile
@fazlurr
fazlurr / kill-slow-ops.js
Created January 27, 2025 08:48
MongoDB - Kill Slow Operations
var killLongRunningOps = function (table = 'submission', maxSecsRunning = 5000, kill = false) {
var ns = 'orderonline_db.' + table;
if (table === '*') {
ns = /^orderonline_db\./;
}
var currOp = db.currentOp({"active" : true,"secs_running" : { "$gt" : maxSecsRunning },"ns" : ns});
var operations = currOp.inprog;
for (var i = 0; i < operations.length; i++) {
var operation = operations[i];
print(i + ". Operation: " + operation.opid);
@fazlurr
fazlurr / precommit.sh
Created January 9, 2025 16:08
Precommit Lint Staged File
#!/bin/bash
clear
fileList=$(git diff --diff-filter=d --cached --name-only | grep -E '\.(js|vue)$')
if [ ${#fileList} -lt 1 ]; then
echo -e "You have no staged .js or .vue files to test\n"
exit
fi
npx eslint ${fileList[*]} "$@"
if [ $? -ne 0 ]; then
echo -e "\nPlease fix the above linting issues before committing.\n"
@fazlurr
fazlurr / read-excel.php
Created September 30, 2022 07:23
Read Excel in PHP
<?php
use Shuchkin\SimpleXLSX;
...
$file = $request->file('file');
$file_path = $file->getRealPath();
if ( $xlsx = SimpleXLSX::parse($file_path) ) {
$rows = $xlsx->rows();
// Degrees to Radians
export const degsToRads = deg => (deg * Math.PI) / 180.0;
// Radians to Degrees
export const radsToDegs = rad => rad * 180 / Math.PI;
// Round like PHP Function
export const round = (num, dec) => {
var num_sign = num >= 0 ? 1 : -1;
return parseFloat((Math.round((num * Math.pow(10, dec)) + (num_sign * 0.0001)) / Math.pow(10, dec)).toFixed(dec));
@fazlurr
fazlurr / API Contract Example Spec.md
Created June 7, 2022 03:13 — forked from BeattieM/API Contract Example Spec.md
An example of an API contract between the server and front-end devices

#Users

  • User object
{
  id: integer
  username: string
  email: string
  created_at: datetime(iso 8601)
  updated_at: datetime(iso 8601)
}
@fazlurr
fazlurr / send-outbound-message.md
Created April 7, 2022 03:29 — forked from nurcholisart/send-outbound-message.md
Documentation on how to send outbound message in Qiscus Multichannel via REST API

Send Outbound Message

Send individual message

Verb

POST https://multichannel.qiscus.com/api/v3/admin/broadcast/client
@fazlurr
fazlurr / nginx-tuning.md
Created July 8, 2021 17:42 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

<script>
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.createTemplateTagFirstArg=function(f){return f.raw=f};$jscomp.createTemplateTagFirstArgWithRaw=function(f,g){f.raw=g;return f};
(function(f,g){g=void 0===g?!1:g;var l=function(c,a,d){d=void 0===d?!1:d;a||(a=window.location.href);c="[?&]"+c.replace(/[\[\]]/g,"\\$&")+"(=([^&#]*)|&|#|$)";a=(d?new RegExp(c):new RegExp(c,"i")).exec(a);if(!a)return null;if(!a[2])return"";a=(a=a[2].replace(/\+/g," "))?decodeURIComponent(a.replace(/%(?![0-9][0-9a-fA-F]+)/g,"%25")):a;return a=a.replace(/[&<>="#;]/g,"")},m=function(c){c+="=";for(var a=document.cookie.split(";"),d=0;d<a.length;d++){for(var b=a[d];" "===b.charAt(0);)b=b.substring(1,b.length);
if(0===b.indexOf(c))return b.substring(c.length,b.length)}return null},n=function(c,a){var d=encodeURIComponent,b=function(e){return e+"="+c[e]};(void 0===a?0:a)&&(b=function(e){return d(e)+"="+d(c[e])});return Object.keys(c).map(b).join("&")};setTimeout(function(){var c=f;c=void 0===c?"oo-link":c;var a=l("fbclid"),d=m("fbp")
<script>
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.createTemplateTagFirstArg=function(f){return f.raw=f};$jscomp.createTemplateTagFirstArgWithRaw=function(f,g){f.raw=g;return f};
(function(f){var g=function(d,a,c){c=void 0===c?!1:c;a||(a=window.location.href);d="[?&]"+d.replace(/[\[\]]/g,"\\$&")+"(=([^&#]*)|&|#|$)";a=(c?new RegExp(d):new RegExp(d,"i")).exec(a);if(!a)return null;if(!a[2])return"";a=(a=a[2].replace(/\+/g," "))?decodeURIComponent(a.replace(/%(?![0-9][0-9a-fA-F]+)/g,"%25")):a;return a=a.replace(/[&<>="#;]/g,"")},l=function(d){d+="=";for(var a=document.cookie.split(";"),c=0;c<a.length;c++){for(var b=a[c];" "===b.charAt(0);)b=b.substring(1,b.length);if(0===b.indexOf(d))return b.substring(d.length,
b.length)}return null},m=function(d,a){var c=encodeURIComponent,b=function(e){return e+"="+d[e]};(void 0===a?0:a)&&(b=function(e){return c(e)+"="+c(d[e])});return Object.keys(d).map(b).join("&")};setTimeout(function(){var d=f;d=void 0===d?"oo-link":d;var a=g("fbclid"),c=l("fbp"),b=l("fbc");d=docume
const query = {};
query.until = until;
const params = { query };
this.$router.push(params);