Skip to content

Instantly share code, notes, and snippets.

View ekardon's full-sized avatar

Mümin Bilal KILIÇOĞLU ekardon

  • İstanbul, Turkey
View GitHub Profile
@ekardon
ekardon / array_of_unknown_length.schema.json
Created October 3, 2023 23:32
Json-schema array examples
{
"description": "First element of the array is integer type and the rest is string type. Array length is unknown",
"type": "array",
"items": [
{
"type": "integer"
}
],
"additionalItems": {
"type": "string"
@ekardon
ekardon / PyCharm Create React App.md
Created November 18, 2022 07:59
A setup to easily handle nodejs and venv

PyCharm Professional 2021.3

  • Create Project

New Project -> Pure Python I use the default values for the following parameters. If you change Virtual env or its location you will need to update some parts according to your changes. New encironment using "Virtualenv" Location: $PROJECT_DIR\venv Base interpreter: Python3.10

@ekardon
ekardon / PyCharm_PowerShell_Fix.ps1
Last active November 18, 2022 07:59
Fix PowerShell not starting with automatically in Terminal tab.
# Rename the file to: Microsoft.PowerShell_profile.ps1
# Replace it under default PS profile folder: C:\Users\<your_username>Documents\WindowsPowerShell
function Test-JetBrains-Product {
# The following enviromental variables are created with venv Pycharm 2021.3. I haven't tested any other product.
return (Test-Path Env:IDEA_INITIAL_DIRECTORY) -And (Test-Path Env:__INTELLIJ_COMMAND_HISTFILE__)
}
function Get-JetBrains-Product {
@ekardon
ekardon / clean_migrate.ps1
Created January 26, 2022 00:09
This script will let you easily undone migrations, remove migration files, re-migrate and createsuperuser in one go.
<#
This script will let you easily undone migrations, removing migration files, re-migrate and createsuperuser.
It's cumbursome to do this all the time by hand. Well, normally you wouldn't need to do this very frequently,
but for beginners like me, it is convinient to have a script to automate this.
#>
# Find manage.py and set project folder accordingly
$manager = Get-Item -Path ".\*", ".\*\*" | Where-Object {$_.name -match "manage.py"}
@ekardon
ekardon / Introduction.md
Created January 11, 2022 13:49
Personel Workspace on Amazon EC2 instance

So I have been trying to create a workspace for myself to develop Django project using postgresql 14.1, python3.9.5 and PyCharm.

Amazon has a product for this "Amazon Workspaces" and its free ties provides 40 hours/month free usage over 1 year. However that's not enough to develop a software or whatsoever. So i wanted to figure out how I can create a workspace on my own using "Amazon EC2" instances which has 750 hours/month over a year.

Here, I will share my trial and error results.

Amazon Workspaces: What is it? Is it free?

Amazon Workspaces is a neat platform where you can use a cloud desktop instance in anywhere. There are multiple client apps for almost any platform (Windows, Linux, MacOS, Android, iOS, web client)

<#
Example appxpackage manifest structure:
>(Get-Appxpackage *windowsstore* | Get-appxpackagemanifest).package
IgnorableNamespaces : uap mp rescap wincap build
xmlns : http://schemas.microsoft.com/appx/manifest/foundation/windows10
mp : http://schemas.microsoft.com/appx/2014/phone/manifest
uap : http://schemas.microsoft.com/appx/manifest/uap/windows10
rescap : http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities
@ekardon
ekardon / appx_install.ps1
Created November 27, 2021 16:41
Appx installer with dependencies
<#
Folder structure:
./
├─ Main.appxbundle
├─ Dependencies/
├─ Dependency1.appx
├─ Dependency2.appx
#>
@ekardon
ekardon / ctypes_example.py
Last active May 4, 2021 18:05
This is a partial snippet, so there may be some missing/undefined parts
from ctypes import CFUNCTYPE, c_int, POINTER, byref, c_char_p, c_har, c_vooid_p, c_uint
# SOURCE: https://docs.nvidia.com/deploy/nvml-api/group__nvmlDeviceQueries.html
class nvmlPciInfo_t(Structure):
_fields_ = [
("bus", c_uint), # 0 to 0xff
("busId", c_char * NVML_DEVICE_PCI_BUS_ID_BUFFER_SIZE), # string + 0x00
("busIdLegacy", c_char * NVML_DEVICE_PCI_BUS_ID_BUFFER_V2_SIZE), # string + 0x00
("device", c_uint), # 0 to 31
# BASH ISN'T PREINSTALLED SO YOU HAVE TO MANUALLY INSTALL IT TO USE THIS SCRIPT
tce-load -iw bash
# FIX WRONG TIME TO SOLVE SSL PROBLEMS
tce-load -iw ntpclient
sudo ntpclient -s -c 1 -h pool.ntp.org
# REQUIRED PACKAGE LIST
# https://xmrig.com/docs/miner/build/ubuntu
tce-load -iw git compiletc cmake automake autoconf libtool libtool-dev
# get OpenCL driver automated installer (installs kernel 4.7)
curl https://software.intel.com/sites/default/files/managed/f6/77/install_OCL_driver.sh_.txt > install_OCL_driver.sh
chmod +x install_OCL_driver.sh
# install OpenCL driver
sudo ./install_OCL_driver.sh install
# check
ls /boot/vmlinuz-*intel*