Skip to content

Instantly share code, notes, and snippets.

View grim-reapper's full-sized avatar

Imran Ali grim-reapper

View GitHub Profile
// Core assets
let coreAssets = [];
// On install, cache core assets
self.addEventListener('install', function (event) {
// Cache core assets
event.waitUntil(caches.open('app').then(function (cache) {
for (let asset of coreAssets) {
cache.add(new Request(asset));
@grim-reapper
grim-reapper / Response.php
Created October 11, 2022 12:09 — forked from jeffochoa/Response.php
Laravel HTTP status code
<?php
// This can be found in the Symfony\Component\HttpFoundation\Response class
const HTTP_CONTINUE = 100;
const HTTP_SWITCHING_PROTOCOLS = 101;
const HTTP_PROCESSING = 102; // RFC2518
const HTTP_OK = 200;
const HTTP_CREATED = 201;
const HTTP_ACCEPTED = 202;
@grim-reapper
grim-reapper / laravel-ci-cd-workflow.yml
Created September 16, 2022 18:28 — forked from JustinByrne/laravel-ci-cd-workflow.yml
Github Action to test laravel and then compile the assets to a production branch
name: CI/CD workflow
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
testing:
@grim-reapper
grim-reapper / .bash_profile
Created September 7, 2022 09:03 — forked from JeffreyWay/.bash_profile
Laravel aliases
# laravel new-app
alias laravel="git clone -o laravel -b develop https://github.com/laravel/laravel.git"
alias artisan="php artisan"
alias migrate="php artisan migrate"
alias serve="php artisan serve"
alias dump="php artisan dump"
alias t="phpunit"
# Generators Package
@grim-reapper
grim-reapper / starship.toml
Created September 7, 2022 09:03 — forked from ryo-ARAKI/starship.toml
Starship configuration file
# ~/.config/starship.toml
[battery]
full_symbol = "🔋"
charging_symbol = "🔌"
discharging_symbol = "⚡"
[[battery.display]]
threshold = 30
style = "bold red"
import { MiddlewareFn } from "type-graphql";
import { redis } from "./redis";
import { MyContext } from "./types/MyContext";
const ONE_DAY = 60 * 60 * 24;
export const rateLimit: (limit?: number) => MiddlewareFn<MyContext> = (
limitForAnonUser = 50,
limitForUser = 100
) => async ({ context: { req }, info }, next) => {
@grim-reapper
grim-reapper / upload.js
Created July 1, 2022 10:11 — forked from jamielob/upload.js
Upload image from React Native to Cloudinary
var CryptoJS = require('crypto-js');
function uploadImage(uri) {
let timestamp = (Date.now() / 1000 | 0).toString();
let api_key = 'your api key'
let api_secret = 'your api secret'
let cloud = 'your cloud name'
let hash_string = 'timestamp=' + timestamp + api_secret
let signature = CryptoJS.SHA1(hash_string).toString();
let upload_url = 'https://api.cloudinary.com/v1_1/' + cloud + '/image/upload'
(function () {
function loadZendeskChat(callback) {
var zdscript = document.createElement('script');
zdscript.setAttribute('id','ze-snippet');
zdscript.src = 'https://static.zdassets.com/ekr/snippet.js?key=XXX-XXX-XXX-XXX';
(document.getElementsByTagName('body')[0]).appendChild(zdscript);
window.zdonload = setInterval(function(){
if(typeof zE !== "undefined" && typeof zE.activate !== "undefined") {
@grim-reapper
grim-reapper / README.md
Created February 10, 2022 18:29 — forked from ahsankhatri/README.md
Database Driven Routes Laravel 5.2

Database Driven Routes Laravel 5.2

Table: url_alias

+----+-----------------+-------------------------------------------+-----------------+-----------+------------+
| id | slug            | map_to                                    | params          | http_verb | middleware |
+----+-----------------+-------------------------------------------+-----------------+-----------+------------+
| 1  | page/about-us   | Frontend\HomeController@showPage          | a:1:{i:0;i:4;}  | GET       | web        |
| 2  | page/contact-us | Backend\DashboardController@getContactUs  | a:1:{i:0;i:4;}  | GET       | web        |

| 3 | page/contact-us | Backend\DashboardController@postContactUs | | POST | web |

@grim-reapper
grim-reapper / powerOfTwo.php
Created February 10, 2022 18:27 — forked from ahsankhatri/powerOfTwo.php
Check if number is a power of 2
<?php
function isPowerOfTwo($num)
{
return ($num > 0) && (($num & ($num - 1)) == 0);
}
// var_dump(4);
// var_dump(5);
// var_dump(6);