Skip to content

Instantly share code, notes, and snippets.

View atikhashmee's full-sized avatar
🎰
Focusing

Atik Bin Hashmee atikhashmee

🎰
Focusing
View GitHub Profile
@atikhashmee
atikhashmee / SpSeeder.php
Created May 10, 2023 16:10
Laravel code to create store procedure code into mysql server
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class SpSeeder extends Seeder
{
/**
@atikhashmee
atikhashmee / conditional_mysql_subquery.php
Created May 10, 2023 15:54
get the suitable discount coupon based on input criteria
<?php
namespace App\Http\Controllers\Contributor;
use App\Models\Order;
use Illuminate\Support\Facades\DB;
use App\Models\Discount as DiscountModel;
trait Discount {
public function totalUsageCoupon($discount_id, $coupon) {
@atikhashmee
atikhashmee / autoexec.cfg
Created June 10, 2022 14:17
Urban terror script
// In this file you can define settings that will be executed everytime Urban Terror is launched. They will not get overwritten.
// Lines starting with // are ignored.
// Example 1: exec yourconfig.cfg
// Example 2: set cg_fov "100"
// Example 3: bind x ut_weaptoggle knife
# bind uparrow "+vstr do_zoom_on do_zoom_off"
# set do_zoom_on "ut_zoomin"
# set do_zoom_off "ut_zoomreset"
bind MOUSE3 "+vstr zoom_toggle" // Zoom Toggle
bind MOUSE2 "+vstr zoom_in zoom_out" // Zoom Key
@atikhashmee
atikhashmee / git.sh
Created January 31, 2022 08:34
basic git command script using bash
#git add
git add .
while getopts b:c: flag
do
case "${flag}" in
b) branch="${OPTARG}";;
c) comment="${OPTARG}";;
esac
done
@atikhashmee
atikhashmee / IndexDB-async-start.js
Last active August 29, 2021 04:13
simple indexDB API (sample), Just to get started with IndexedDB, Don't scrabble too much, get an idea in a bulk in this link (https://dev.opera.com/articles/introduction-to-indexeddb/)
let DBSingleton = (function(version) {
let instance = null
function createInstance() {
let request = indexedDB.open('idea_ecom', version)
return request;
}
return {
getInstance: function() {
if (!instance) {
instance = createInstance()
@atikhashmee
atikhashmee / sequentail.js
Last active February 22, 2021 07:13
Sequential and parallel async calling
function fetchUrl(url) {
return fetch(url.url).then(item=>item.json());
}
const urls = [{
url: 'https://jsonplaceholder.typicode.com/users'
},
{
url: 'https://jsonplaceholder.typicode.com/todos'
}
@atikhashmee
atikhashmee / error-handling-with-fetch.md
Created April 24, 2020 21:28 — forked from odewahn/error-handling-with-fetch.md
Processing errors with Fetch API

I really liked @tjvantoll article Handling Failed HTTP Responses With fetch(). The one thing I found annoying with it, though, is that response.statusText always returns the generic error message associated with the error code. Most APIs, however, will generally return some kind of useful, more human friendly message in the body.

Here's a modification that will capture this message. The key is that rather than throwing an error, you just throw the response and then process it in the catch block to extract the message in the body:

fetch("/api/foo")
  .then( response => {
    if (!response.ok) { throw response }
    return response.json()  //we only get here if there is no error
 })
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<button type="button" onclick="cart(1)"> counter +1</button>
<p id="showCounter">0</p>
@atikhashmee
atikhashmee / header.cpp
Last active August 29, 2018 18:10
Header file library
#include <bits/stdc++.h>
#define min(a,b) (a>b)?b:a
#define max(a,b) (a>b)?a:b
using namespace std;
struct Pair {
int min;
int max;
/*
bismillahir rahmanir rahim
problem link : http://codeforces.com/problemset/problem/339/A
problem type : brutforce
*/
#include <bits/stdc++.h>