Skip to content

Instantly share code, notes, and snippets.

View amenayach's full-sized avatar

Amen Ayach amenayach

View GitHub Profile
@amenayach
amenayach / sort_dir.py
Created October 11, 2022 23:46
A python script that sort a folder content considering not only files but folders.
import os,sys,time
def get_size(start_path = '.'):
total_size = 0
for dirpath, _, filenames in os.walk(start_path):
for file in filenames:
file_path = os.path.join(dirpath, file)
total_size += os.path.getsize(file_path)
return total_size
@amenayach
amenayach / Obfuscar.txt
Created May 14, 2021 20:02
Obfuscar sample config tested on dotnet core 2.2
<YouProject>.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
@amenayach
amenayach / youtube-playlist-scraping.js
Last active May 1, 2022 00:51
A Javascript script to scrap Youtube playlist via browser console
let getSeconds = secondsText => {
let spl = secondsText.split(':');
return parseInt(spl[0]) * 60 + parseInt(spl[1]);
};
let getEmbedUrl = url => {
let vIndex = url.indexOf('?v=');
let lIndex = url.indexOf('&list=');
return 'https://www.youtube.com/embed/' + url.substring(vIndex + 3, lIndex);
};
@amenayach
amenayach / django_crash_course.MD
Created December 31, 2020 16:54 — forked from bradtraversy/django_crash_course.MD
Commands for Django 2.x Crash Course

Django Crash Course Commands

# Install pipenv
pip install pipenv
# Create Venv
pipenv shell
@amenayach
amenayach / django_deploy.md
Created November 27, 2020 13:18 — forked from bradtraversy/django_deploy.md
Django Deployment - Digital Ocean

Django Deployment to Ubuntu 18.04

In this guide I will go through all the steps to create a VPS, secure it and deploy a Django application. This is a summarized document from this digital ocean doc

Any commands with "$" at the beginning run on your local machine and any "#" run when logged into the server

Create A Digital Ocean Droplet

Use this link and get $10 free. Just select the $5 plan unless this a production app.

@amenayach
amenayach / Nester.cs
Last active May 13, 2020 23:30
A CSharp class that builds a nested tree out of a flat collection
public sealed class Nester<T, TSortKey> : IDisposable
{
private readonly IEnumerable<T> flatList;
private Func<T, T, bool> parentChildPredicate;
private PropertyInfo nestingPropertyInfo;
private Func<T, TSortKey> sortingKeySelector;
private Func<T, bool> rootLevelPredicate;
private Nester(IEnumerable<T> flatList,
Func<T, bool> rootLevelPredicate,
@amenayach
amenayach / random-string.js
Created December 6, 2019 08:22
Generates random alpha numeric string
function getRandomChar(isChar) {
return parseInt(Math.random() * 100) % (isChar === true ? 26 : 10);
}
function getRandomString(length) {
return [...new Array(length)]
.map((x, i) =>
i % 2 === 0 ?
String.fromCharCode(65 + getRandomChar(true)).toString() :
getRandomChar(false).toString())
@amenayach
amenayach / LebanonFiles.py
Last active October 30, 2019 08:53
Simple python script that retrieves Lebanon files site latest news (use Jupyter for best view)
from requests import get
from requests.exceptions import RequestException
from contextlib import closing
from bs4 import BeautifulSoup
#Best used via Jupyter
def download_text(url):
try:
with closing(get(url, stream=True)) as resp:
if is_good_response(resp):