Skip to content

Instantly share code, notes, and snippets.

View ali-master's full-sized avatar
🎯
Focusing on Something new!

Ali Torki ali-master

🎯
Focusing on Something new!
View GitHub Profile
@ruizb
ruizb / README.md
Last active February 22, 2024 15:46
A glossary of TypeScript.

A glossary of TypeScript

Motivation

Once upon a time, there was a developer that had an issue using the TypeScript language. He wanted to share his issue with the community to get help, but he didn't know how to properly write the title that would best describe his problem. He struggled to find the appropriate words as he didn't know how to name "this behavior" or "that kind of type mechanism".

This story encouraged me to start writing a glossary of TypeScript. Hopefully it will help you if you have to look for an issue, write an issue, or communicate with other TypeScript developers.

Disclaimer: it was me, I was the developer that struggled. I still struggle though, but this means I still have things to learn, which is great!

@farhadshiri
farhadshiri / exploit.asm
Last active January 7, 2023 19:37
DNS Response Denial-of-Service
; HOD-symantec-firewall-DoS-expl.asm:
; Symantec Multiple Firewall DNS Response Denial-of-Service
; -------------------------------------------------------------------
; By f.shiri 2020
; farhad.shiri.ex@gmail.com
; -------------------------------------------------------------------
; Tested on:
; - Symantec Norton Personal Firewall
; Systems Affected:
; -------------------------------------------------------------------
@m-khooryani
m-khooryani / Program.cs
Created June 9, 2020 16:10
Longest substring with K unique characters
class Program
{
static void Main(string[] args)
{
Console.WriteLine(LongestSubstringWithKUniqueChars("abcba", 2));
}
private static string LongestSubstringWithKUniqueChars(string s, int k)
{
if (k == 0)
@cvan
cvan / css-ios-pwa-viewport.css
Created April 3, 2020 22:14
CSS for env(safe-area-inset-top) for iOS "Add to Homescreen" / PWA; standalone styles
@supports (padding-top: constant(safe-area-inset-top)) {
body {
padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
}
@media (display-mode: fullscreen) {
body {
padding: 0;
}
// this code is executed in the context of each tab
import {Workbox} from 'workbox-window';
if ('serviceWorker' in navigator) {
const wb = new Workbox('/sw.js');
wb.addEventListener('waiting', () => {
console.log('A new service worker has installed');
wb.addEventListener('controlling', () => {

CockroachDB and Docker Compose

This is the first in a series of tutorials on CockroachDB and Docker Compose

  • Information on CockroachDB can be found here.
  • Information on Docker Compose can be found here
  1. Install Docker Desktop

Because we already have an official CockroachDB docker image, we will use that in our docker-compose.yml file. We recommend you use one of the current tags instead of latest.

@arash16
arash16 / 0-blue-green-deployment.sh
Last active February 25, 2023 17:46
Sample minimal blue/green deployment strategy codes used on cafebazaar.ir
# this is a minimal sample code used for ci pipelines to implement blue/green deployment
// Simplified Sample Code for limiting nuxt ssr per user
const { RateLimiterMemory } = require("rate-limiter-flexible");
const { cpuFree } = require('os-utils');
// each user has 1SSR per minute
const ipRateLimiter = new RateLimiterMemory({
points: 1, // 1 SSR
duration: 60, // Per minute
});
export default function asyncDataWrapper(originalAsyncData) {
return async function(ctx) {
try {
return await originalAsyncData.call(this, ctx);
}
catch (e) {
// statusCode=1 is connectivity error (assigned inside API-Layer)
if (process.client && e.statusCode === 1) {
window.addEventListener('online', () => {
// reload the page when connection is back
@jamesseanwright
jamesseanwright / lazy-routes.tsx
Created July 17, 2019 16:40
Lazy route loading with React.lazy and Suspense
import * as React from 'react';
import Nav from './Nav.jsx';
import { Router } from './routing';
const routes = new Map<string, React.ComponentType>([
['/', () => <p>Pick an Ipsum!</p>],
['/lorem', React.lazy(() => import('./pages/Lorem'))],
['/bacon', React.lazy(() => import('./pages/Bacon'))],
['/hipster', React.lazy(() => import('./pages/Hipster'))],
['/office', React.lazy(() => import('./pages/Office'))],