Skip to content

Instantly share code, notes, and snippets.

View nadyshalaby's full-sized avatar
🏠
Working from home

Nady Shalaby nadyshalaby

🏠
Working from home
View GitHub Profile
@nadyshalaby
nadyshalaby / .deps...npm...hardhat...console.sol
Created August 2, 2023 01:35
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.18+commit.87f61d96.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;
library console {
address constant CONSOLE_ADDRESS =
0x000000000000000000636F6e736F6c652e6c6f67;
function _sendLogPayloadImplementation(bytes memory payload) internal view {
address consoleAddress = CONSOLE_ADDRESS;
/// @solidity memory-safe-assembly
@nadyshalaby
nadyshalaby / bitbucket-pipelines.yml
Last active June 26, 2023 08:02
How to deploy a NestJs Application on GCP Compute Engine
image: atlassian/default-image:3
pipelines:
branches:
develop:
- step:
name: Deploy to GCP
caches:
- docker
script:
@nadyshalaby
nadyshalaby / Dockerfile
Last active June 26, 2023 08:27
How to deploy a NestJs Application on Cloud Run Service using CloudBuild and Docker
FROM node:lts-alpine3.18
WORKDIR /app
COPY package.json .
RUN yarn
COPY . .
RUN yarn build
EXPOSE 3000
CMD [ "yarn", "start:prod" ]
@nadyshalaby
nadyshalaby / JsTranslationsServiceProvider.php
Created April 9, 2023 02:00
Laravel blade directive to load laravel lang files using helper like the translation helper that laravel uses `__(key, [])`
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
class JsTranslationsServiceProvider extends ServiceProvider
{
public function register(): void
@nadyshalaby
nadyshalaby / 0- install nodejs and redis.sh
Created December 27, 2022 23:27 — forked from moaalaa/0- install nodejs and redis.sh
How to run PM2 with laravel queue and laravel echo server
# Node Js
curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -
sudo yum install nodejs
node --version
npm --version
# Redis
@nadyshalaby
nadyshalaby / decode.ts
Created September 9, 2022 09:36 — forked from chjlsch/decode.ts
recursively encode and decode querystrings (encode = object to querystring, decode = querystring to object)
export function decode(querystring: string): object {
function parseValue(value: string): any {
if (value === 'TRUE') return true;
if (value === 'FALSE') return false;
return isNaN(Number(value)) ? value : Number(value);
}
function dec(list: any[], isArray = false): object {
let obj: any = isArray ? [] : {};
@nadyshalaby
nadyshalaby / Laravel Vite SSL on Localhost
Created September 5, 2022 09:04
Enable SSL on Laravel Vite Project
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
server: {
https: {
key: "/opt/homebrew/etc/httpd/certs/syanat-app.test-key.pem",
cert: "/opt/homebrew/etc/httpd/certs/syanat-app.test.pem",
},
host: 'syanat-app.test',
@nadyshalaby
nadyshalaby / Copy to Clipboard using Javascript
Created August 25, 2022 04:46
Snippet that allows you to copy data to clipboard using javascript
function fallbackCopyTextToClipboard(text) {
var textArea = document.createElement("textarea");
textArea.value = text;
// Avoid scrolling to bottom
textArea.style.top = "0";
textArea.style.left = "0";
textArea.style.position = "fixed";
document.body.appendChild(textArea);
@nadyshalaby
nadyshalaby / worktree.md
Last active May 26, 2022 14:25
Git Worktree Most Used Command

Worktree most used commands

To open worktree from current bransh

git worktree add --detach <worktree-path> <branch-name>

To open worktree from remote branch

git worktree add --detach <worktree-path> <remote-name>/<branch-name>

To open worktree from commit

git worktree add --detach

@nadyshalaby
nadyshalaby / merge-tables.sql
Created April 20, 2022 13:11
This sql script can merge two tables with different columns without carrying out the headache of specifying the whole list of column names. This script can guess the match column names and remove duplicates on insertion process.
SET @target_table = '`klame_new`.`url`';
SET @source_table = '`klame_url`.`url`';
SELECT GROUP_CONCAT(column_name)
FROM INFORMATION_SCHEMA.COLUMNS a
WHERE a.TABLE_NAME = 'url'
AND a.TABLE_SCHEMA = 'klame_url'
AND a.COLUMN_NAME IN (
SELECT b.COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS b