Skip to content

Instantly share code, notes, and snippets.

View shoaibi's full-sized avatar

Shoaibi shoaibi

View GitHub Profile
import React, { useState } from "react";
import DOMPurify from 'dompurify';
function Xss(){
const [text, setText] = useState("");
const [script, setScript] =useState("");
const [imgg, setimgg] = useState("");
@shoaibi
shoaibi / DynamoDb.md
Last active April 1, 2020 08:07
DynamoDb Notes

General

  • Data Pressure: Ability to process data within reasonable time and cost
  • Whenever one of the dimensions of Data Pressure is broken, we'd invent new technology.
  • RDBMs optimize for storage which makes sense as storage was expensive in 70s. But this happens at the cost of CPU, where CPU is going insane pulling data from all over the disk and stitch it together. Nowadays storage is cheap and CPU isn't. So why use a system that depends on an expensive resource.
  • RDBMs/SQL gives structure with power to create ad hoc queries while noSQL gives instantiated views for given queries. In this way noSQL forces more product driven development where one has to discover access patterns.
  • noSQL != non-relation. All data in universe is relational.
  • Do not compare RDBMS with noSQL and specially MySQL and DynamoDb.
    • No, Table is not the same, and no Document is not same as records
  • For writes, DynamoDb uses 3 replica and returns when 2 confirm the write

When talking about creating a lot of microservices for one workflow:

Again, this is something that looks good on paper, but immediately leads to several questions:

  • Do you feel the need to deploy six applications to process 1 xml file?

  • Are these microservices really independent from each other? They can be deployed independently from each other? With different

@shoaibi
shoaibi / phpstorm.vmoptions
Created August 2, 2017 07:32
PHPStorm vmoptions
-agentlib:yjpagent=probe_disable=*,disablealloc,disabletracing,onlylocal,disableexceptiontelemetry,delay=10000,sessionname=PhpStorm2016.3
-Dide.no.platform.update=true
-Dsun.io.useCanonCaches=false
-ea
-server
-Xms2048m
-Xmx4096m
-XX:+AggressiveOpts
-XX:+CMSClassUnloadingEnabled
-XX:+CMSIncrementalMode
#!/bin/bash
urlencode() {
# urlencode <string>
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
*) printf '%s' "$c" | xxd -p -c1 |
while read c; do printf '%%%s' "$c"; done ;;
find . -depth -name '* *' \
-execdir bash -c 'mv "$1" "${1// /_}"' _ {} \;
#!/bin/bash
# Without $1, it'd use your Public IP
curl -s http://ip-api.com/json/$1 | python -m json.tool
#!/bin/bash
# Kill all running containers
docker kill $(docker ps -q)
#!/bin/bash
perl -pe 's/(^|_)./uc($&)/ge;s/_//g'
@shoaibi
shoaibi / mysql-restore.sh
Created January 20, 2017 11:44
Restore large databases
echo "Restoring $1"
queries="
-- Set network buffer length to a large byte number\n
set global net_buffer_length=1000000;\n
-- Set maximum allowed packet size to a large byte number\n
set global max_allowed_packet=1000000000;\n
-- Disable foreign key cheking to avoid delays,errors and unwanted behaviour\n
SET foreign_key_checks = 0;\n
source $2;\n