Skip to content

Instantly share code, notes, and snippets.

View smarteist's full-sized avatar
🙂
I may be slow to respond.

Ali Hosseini smarteist

🙂
I may be slow to respond.
View GitHub Profile
@smarteist
smarteist / downloader.sh
Created February 2, 2024 13:13
bash downloader via curl
#!/bin/bash
# Define the list of URLs
urls=(
"https://.mkv"
"https://.mkv"
)
# Define the resumable downloader function
download_file() {
@smarteist
smarteist / sshproxy.sh
Created October 20, 2023 21:41
This script runs ssh proxy in local socks5 port 1080
#!/bin/bash -i
user_at_host="root@<host>"
sudo_pass="password!";
sudo_pass_file="/tmp/sshpass"
interfaces_arr=($(ip route show default | sed -n 's/.* dev \([^\ ]*\) .*src.*/\1/p'))
for i in "${interfaces_arr[@]}"; do
# Activate debugging from here

In Linux, groups are a collection of users. They are used as a means to manage and control access to resources such as files and directories. By assigning appropriate permissions to groups rather than individual users, system administrators can more efficiently manage access rights.

find /path/to/base/dir -type d | xargs chmod 755
find /path/to/base/dir -type f | xargs chmod 644

or changing files with specific extention:

find /path/to/base/dir -iname "*.php" | xargs chmod 644
@smarteist
smarteist / symfony.conf
Created August 1, 2023 16:56
nginx confings for symfony2
# -------------------
# SYMFONY CONF
# -------------------
server {
listen 443 ssl http2;
listen 80;
server_name domain.com www.domain.com;
charset utf-8;
root "/var/www/domain/public_html";
gzip off;
#!/usr/bin/env bash
cpucores="2"
ram="2G"
disk="30G"
username="vm"
password="111111"
vm_name="VM1"
ver="22.04"
img="ubuntu-${ver}-server-cloudimg-amd64.img"
@smarteist
smarteist / ln.py
Last active June 17, 2023 15:15
CORDIC Algorithm to calc natural logarithm in python
import math
def cordic_ln(x):
if x <= 0:
raise ValueError("Input must be greater than 0")
lut = [
2.718281828459045,
1.6487212707001282,
1.2840254166877414,
@smarteist
smarteist / conditional_variable.c
Last active May 12, 2023 14:28
conditional variable api using semaphores!
#include <stdio.h>
#include <pthread.h>
#include <semaphore.h>
#include <unistd.h>
typedef struct {
sem_t wait_sem;
sem_t signal_sem;
int value;
} cond_var_t;
@smarteist
smarteist / sbrk.c
Last active April 22, 2023 15:52
allocate two pages, in C
#include <stdio.h>
#include <unistd.h>
#include <sys/syscall.h>
// same as calling sbrk(0)
void *get_brk (void)
{
return (void *) syscall (SYS_brk, 0);
}
@smarteist
smarteist / vim_tmux.md
Last active April 11, 2024 13:19
Starting With VIM & TMUX

VIM

Quit VIM!

:q + ENTER

Force Quit VIM!

:q! + ENTER

@smarteist
smarteist / relax-supplier-parts.txt
Last active March 24, 2024 20:38
This is relax relational algebra calculator example data
group: SUPPLIER PARTS - S, SP, P
description: This is a very simple database that is used by ChrisDate & HughDarwen throughout their books (e.g., AnIntroductionToDatabaseSystems & TheThirdManifesto) for examples.
P = {
pn, pname, color
1, 'PN1', 'Red'
2, 'PN2', 'Blue'
3, 'PN3', 'Yellow'
4, 'PN4', 'Green'