Skip to content

Instantly share code, notes, and snippets.

View cengizhancaliskan's full-sized avatar
:bowtie:

Cengizhan Çalışkan cengizhancaliskan

:bowtie:
View GitHub Profile
git update-index --add --chmod=+x filename.sh
git commit -m 'filename permission error fixed.'
git push
@cengizhancaliskan
cengizhancaliskan / fiber_mongo.go
Created August 18, 2020 15:20
gofiber mongo crud
// 🚀 Fiber is an Express inspired web framework written in Go with 💖
// 📌 API Documentation: https://fiber.wiki
// 📝 Github Repository: https://github.com/gofiber/fiber
package main
import (
"context"
"log"
"time"
@cengizhancaliskan
cengizhancaliskan / sql
Created March 12, 2021 10:00
Postgresql restart id sequence identity
SELECT MAX(id) FROM "Content";
SELECT nextval('"Content_id_seq"'::text);
BEGIN;
-- protect against concurrent inserts while you update the counter
LOCK TABLE "Content" IN EXCLUSIVE MODE;
-- Update the sequence
SELECT setval('"Content_id_seq"', COALESCE((SELECT MAX(id)+1 FROM "Content"), 1), false);
#!/bin/bash
dir="/Users/$USER/images"
find $dir -type f -name '*.png' -print0 | while IFS= read -r -d '' file; do
convert "$file" "${file%.*}.jpg"
rm -f $file
echo "$file converted"
done
@cengizhancaliskan
cengizhancaliskan / ThreadSafeCounter.py
Created May 24, 2022 12:29
ThreadSafeCounter python
# -*- coding: utf-8 -*-
import threading
class ThreadSafeCounter:
def __init__(self, counter=0, max_counter=0):
self.lock = threading.Lock()
self.counter = counter
self.max_counter = max_counter