Skip to content

Instantly share code, notes, and snippets.

View amjadbouhouch's full-sized avatar
🎯
Focusing

Amjed Bouhouch amjadbouhouch

🎯
Focusing
View GitHub Profile
@amjadbouhouch
amjadbouhouch / docker-compose.yml
Created December 15, 2024 10:24 — forked from JBGruber/docker-compose.yml
My compose file to run ollama and ollama-webui
services:
# ollama and API
ollama:
image: ollama/ollama:latest
container_name: ollama
pull_policy: missing
tty: true
restart: unless-stopped
# Expose Ollama API outside the container stack (but only on the same computer;
@amjadbouhouch
amjadbouhouch / index.js
Created January 18, 2023 22:53 — forked from AnsonT/index.js
Using Node-Jose to for RSA jwt with key store
import { JWE, JWK, JWS } from 'node-jose'
import fs from 'fs'
import { join } from 'path'
import jwkToPem from 'jwk-to-pem'
import jwt from 'jsonwebtoken'
const certDir = '.cert'
const keystoreFile = join(certDir, 'keystore.json')
const raw = {
iss: 'test',
@amjadbouhouch
amjadbouhouch / deploy.sh
Created September 14, 2022 09:53 — forked from dre1080/deploy.sh
Zero Downtime Docker Compose Deploys
#!/usr/bin/env bash
CONTAINER_NAME="$1"
PROJECT_NAME="app"
# lets find the first container
FIRST_NUM=`docker ps | awk '{print $NF}' | grep app_$CONTAINER_NAME | awk -F "_" '{print $NF}' | sort | head -1`
NUM_OF_CONTAINERS=1
MAX_NUM_OF_CONTAINERS=2
@amjadbouhouch
amjadbouhouch / Example.js
Last active September 6, 2022 12:57 — forked from aeciolevy/Example.js
Example of mongoose transaction. MongoDB transaction example
exports.deleteUser = async (req, res, next) {
const session = await mongoose.startSession();
try {
const { id } = req.params;
// Start session
await session.startTransaction();
// deleteMany in this session
const [errorOp, result] = await toAll([App.deleteMany({ user: id }).session(session), UserModel.findByIdAndRemove(id).session(session)]);
if (errorOp) {
throw new ErrorRequest(STATUS_CODE.UNPROCESSABLE, errorOp.message);

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@amjadbouhouch
amjadbouhouch / Notifee.md
Last active January 8, 2022 11:01
Notifee

Receiving Messages FCM

  1. ForegroundState
// any component you want
useEffect(() => {
  const unsubscribe = messaging().onMessage(async (message) => {
    // work
 });
@amjadbouhouch
amjadbouhouch / tools.md
Last active January 19, 2022 12:54
Tools
@amjadbouhouch
amjadbouhouch / react native chat libs.txt
Created October 31, 2021 17:55
react native chat libs
react-native-sound
react-native-vector-icons
react-native-elements
react-native-fast-image
react-native-image-picker
react-native-document-picker
react-native-gesture-handler
react-native-reanimated
reanimated-bottom-sheet
react-native-video
@amjadbouhouch
amjadbouhouch / Docker-cleanup-commands.sh
Last active January 3, 2022 13:53
Docker cleanup commands
#To clear containers
docker rm -f $(docker ps -a -q)
#To clear images:
docker rmi $(docker images -q -f dangling=true)
docker rmi $(docker images -q)
#To clear volumes:
docker volume rm $(docker volume ls -qf dangling=true)
#To clear networks:
docker network rm $(docker network ls | tail -n+2 | awk '{if($2 !~ /bridge|none|host/){ print $1 }}')