Skip to content

Instantly share code, notes, and snippets.

View cengizhancaliskan's full-sized avatar
:bowtie:

Cengizhan Çalışkan cengizhancaliskan

:bowtie:
View GitHub Profile
@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
#!/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 / 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);
@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"
git update-index --add --chmod=+x filename.sh
git commit -m 'filename permission error fixed.'
git push
@cengizhancaliskan
cengizhancaliskan / gist:d51edeb6bc929a5a706b2270797efe70
Created June 26, 2020 20:40
pyenv tkinter problem solve on macos
```bash
$ brew install tcl-tk
$ pyenv uninstall {used_version}
$ env \
PATH="$(brew --prefix tcl-tk)/bin:$PATH" \
LDFLAGS="-L$(brew --prefix tcl-tk)/lib" \
CPPFLAGS="-I$(brew --prefix tcl-tk)/include" \
PKG_CONFIG_PATH="$(brew --prefix tcl-tk)/lib/pkgconfig" \
CFLAGS="-I$(brew --prefix tcl-tk)/include" \
@cengizhancaliskan
cengizhancaliskan / .zshrc
Last active April 7, 2020 21:56
zsh config
export ZSH="/Users/$USER/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="random"
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
@cengizhancaliskan
cengizhancaliskan / Dockerfile
Created March 19, 2020 19:43
jdk gradle dockerfile
FROM openjdk:8-jdk-alpine
##ENV GRADLE_VERSION 6.2.2
##ENV GRADLE_HOME /opt/gradle
##ENV PATH ${PATH}:${GRADLE_HOME}/bin
RUN apk update \
&& apk add --no-cache curl bash
# Install gradle
@cengizhancaliskan
cengizhancaliskan / pandas read csv.py
Created November 21, 2019 13:51
Pandas read csv by with chunk for big size CSV files
filename = 'filename.csv'
chunksize = 10 ** 6
chunk_list = []
for chunk in pd.read_csv(filename, chunksize=chunksize, error_bad_lines=False):
chunk_list.append(chunk)
df = pd.concat(chunk_list)
@cengizhancaliskan
cengizhancaliskan / pandas highlight row.py
Created November 21, 2019 13:38
Pandas highlight row
def highlight(row):
if row > 60:
return 'background-color: green'
else:
return 'background-color: none;'
df = df.style.applymap(highlight, subset=['Term', 'Count'])