Skip to content

Instantly share code, notes, and snippets.

View asilbalaban's full-sized avatar

Asil Balaban asilbalaban

View GitHub Profile
@asilbalaban
asilbalaban / caller.py
Created August 14, 2022 20:25
Read realtime output with python subprocess
import os
import subprocess
import fcntl
import time
def non_block_read(output):
fd = output.fileno()
fl = fcntl.fcntl(fd, fcntl.F_GETFL)
fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
try:
@asilbalaban
asilbalaban / color.py
Last active August 11, 2022 11:10
colored print
class color:
listOfColors = {
"info": "\033[94m",
"secondary": "\033[2m",
"success": "\033[92m",
"warning": "\033[0;33m",
"danger": "\033[0;31m",
"bg_info": "\033[0;44m",
@asilbalaban
asilbalaban / setup.md
Last active July 20, 2022 05:44
www-data ile node çalıştırmak için nvm npm kurulumu
cd /var/www/
sudo mkdir .nvm
sudo mkdir .npm
sudo chown www-data -R .nvm/ .npm/
cd ~
sudo su -s /bin/bash www-data
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
slug = $('#cphPageContent_txtbxStokKodu').val();
slugNum = slug.slice(-2);
newNum = parseInt(slugNum) + 1
if(newNum < 10) {
newNum = "0" + newNum
}
$('#txtbxAdres').val('magaza/bisiklet/aksesuar/m-kbbnd-'+newNum);
$('#txtbxUrunAdi').val('M-KBBND-'+newNum);
$('#cphPageContent_txtbxStokKodu').val('M-KBBND-'+newNum);
@asilbalaban
asilbalaban / counter.py
Created June 7, 2022 07:23
discord count game
import keyboard
import time
import random
# number = 1
number = int(input('en son kac yazilmis: '))
time.sleep(3)
def onkeypress(event):
global number
@asilbalaban
asilbalaban / git-deployment.md
Created April 13, 2022 06:15 — forked from noelboss/git-deployment.md
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

@asilbalaban
asilbalaban / remove-duplicates.php
Created February 23, 2022 08:52
remove duplicate unique column rows in laravel
<?php
Route::get('test', function () {
$raw = \DB::raw('count(*) as total');
$requestCounts = \App\Models\Cards::query()->select('card_slug', $raw)->havingRaw('COUNT(*) > 1')->groupBy('card_slug')->limit(500)->pluck('total', 'card_slug');
if (ob_get_level() == 0) ob_start();
foreach ($requestCounts as $key => $val) {
echo $key . ' - ' . $val . '<br>';
$ids = \App\Models\Cards::where('card_slug', $key)->pluck('id');
unset($ids[0]);
@asilbalaban
asilbalaban / loop.php
Created February 23, 2022 08:44
obflush foreach in php
<?php
$array = ['a', 'b', 'c'];
if (ob_get_level() == 0) ob_start();
foreach ($array as $key => $val) {
echo $key . ' - ' . $val . '<br>';
ob_flush();
flush();
echo '<script>var scrollingElement = (document.scrollingElement || document.body);
scrollingElement.scrollTop = scrollingElement.scrollHeight;</script>';
@asilbalaban
asilbalaban / chmod laravel
Created February 1, 2022 11:57
laravel chmod
cd /var/www/laravel_project
php artisan cache:clear
php artisan config:clear
sudo service apache2 stop
sudo chown -R $USER:www-data storage
sudo chown -R $USER:www-data bootstrap/cache
chmod -R 775 storage
chmod -R 755 bootstrap/cache
sudo service apache2 start
laravel'de artisan tarafından çalıştırılan cronjoblar, eventler ve joblar'ın oluşturduğu error log ile www-data tarafından çalışan dosyaların oluşturduğu error log farklı kullanıcılar tarafından yaratıldığından yazma izni hatasına sebep verebilir.
bu durumun kolayca önüne geçmek için iki farklı log dosyası oluşmasını sağlayabilirsiniz. bu durumda config klasörü içindeki logging.php dosyasında ufak bir değişiklik yapacağız.
kullandığınız driver içindeki path bölümünü
'path' => storage_path(
function_exists('posix_getpwuid')
&& function_exists('posix_geteuid')
? 'logs/laravel'
. '-' . php_sapi_name()