Skip to content

Instantly share code, notes, and snippets.

@Tapanhaz
Tapanhaz / benchmark.py
Last active March 27, 2025 09:23
Compare if-else, match-case, dict lookup
import timeit
import random
def if_elif_else_lookup(n):
if n == 0:
return "zero"
elif n == 1:
return "one"
elif n == 2:
return "two"

Ingredients

  • 250g lentils
  • 1 oinion
  • 3 garlic cloves
  • 1 fat tomatoe
  • 3 tbsp. olive oil
  • 1 tsp. of tomatoe paste
  • 1.5 tsp. of poudered cumin
  • 1 tsp. of poudered curcuma (or turmeric)
@Tapanhaz
Tapanhaz / usleep.c
Created March 9, 2025 20:51 — forked from ngryman/usleep.c
usleep for Windows.
void usleep(DWORD waitTime){
LARGE_INTEGER perfCnt, start, now;
QueryPerformanceFrequency(&perfCnt);
QueryPerformanceCounter(&start);
do {
QueryPerformanceCounter((LARGE_INTEGER*) &now);
} while ((now.QuadPart - start.QuadPart) / float(perfCnt.QuadPart) * 1000 * 1000 < waitTime);
}
@Tapanhaz
Tapanhaz / pthreads_cython.pyx
Last active February 26, 2025 05:08 — forked from jerryvig/pthreads_cython.pyx
Basic demonstration of how to use pthreads (POSIX threads) in Cython.
from cython.operator cimport dereference
from posix.unistd cimport usleep
from libc.stdio cimport printf
from libc.stdint cimport intptr_t
cdef extern from "pthread.h" nogil:
ctypedef int pthread_t
ctypedef struct pthread_attr_t:
pass
cdef int pthread_create(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine) (void *), void *arg)
# https://www.quantopian.com/posts/technical-analysis-indicators-without-talib-code
import numpy
import pandas as pd
import math as m
#Moving Average
def MA(df, n):
MA = pd.Series(pd.rolling_mean(df['Close'], n), name = 'MA_' + str(n))
df = df.join(MA)
@Tapanhaz
Tapanhaz / oracle-cloud-free-tier-guide.md
Created December 31, 2024 06:54 — forked from rssnyder/oracle-cloud-free-tier-guide.md
oracle-cloud-free-tier-guide

how to leverage oracle's temping offers

free tier limits

The limits of the free tier say that you can create up to 4 instances.

  • x2 x86 instances (2core/1g)
  • x2 ampere instances (with 4core/24g spread between them)
  • 200GB total boot volume space across all intances (minimum of 50G per instance)

create your account

@Tapanhaz
Tapanhaz / ioctl.py
Created November 27, 2024 19:10 — forked from santa4nt/ioctl.py
A Python-ctypes script to dispatch IOCTL in Windows
#!C:\Python27\python.exe
# The MIT License (MIT)
#
# Copyright © 2014-2016 Santoso Wijaya <[email protected]>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sub-license, and/or sell copies of the Software,
@Tapanhaz
Tapanhaz / JetBrains trial reset.md
Created November 21, 2024 03:25
Reset all JetBrains products trial in Linux

In some cases, only these lines will work

for product in IntelliJIdea WebStorm DataGrip PhpStorm CLion PyCharm GoLand RubyMine; do
    rm -rf ~/.config/$product*/eval 2> /dev/null
    rm -rf ~/.config/JetBrains/$product*/eval 2> /dev/null
done

But if not, try these

REM Delete eval folder with licence key and options.xml which contains a reference to it
for %%I in ("WebStorm", "IntelliJ", "CLion", "Rider", "GoLand", "PhpStorm", "Resharper", "PyCharm") do (
for /d %%a in ("%USERPROFILE%\.%%I*") do (
rd /s /q "%%a/config/eval"
del /q "%%a\config\options\other.xml"
)
)
REM Delete registry key and jetbrains folder (not sure if needet but however)
rmdir /s /q "%APPDATA%\JetBrains"
@Tapanhaz
Tapanhaz / JetBrainsTrial.bat
Created November 21, 2024 03:19 — forked from MrPaXe/JetBrainsTrial.bat
Infinite Jetbrains Resharper trial
:: This bat file can be used to renew Resharper C# and Resharper C++ every time it runs out
:: It most likely works for all Jetbrains tools, however, I did not test this.
:: I was not able to find the original author for the reg key and the folders that needs to be deleted so if that is you feel free to reach out for credit
@echo off
setlocal enableDelayedExpansion
:confirm
echo Did you stop all Jetbrains services?
echo Jetbrains toolbox AND any other tool using it such as Rider, Visual Studio, ...