Skip to content

Instantly share code, notes, and snippets.

View ThoenigAdrian's full-sized avatar
🎯
Focusing

ThoenigAdrian

🎯
Focusing
View GitHub Profile
@ThoenigAdrian
ThoenigAdrian / gist:065f540dba8f39ad89a71d1e5cca3c3f
Created October 3, 2024 14:13
Get all file hashes in power shell in folder
PS C:\Users\aibotics\source\repos\TorchProject1\TorchProject1\x64\Release> Get-ChildItem -File | Sort-Object Name | ForEach-Object {
>> $hash = Get-FileHash $_.FullName
>> [PSCustomObject]@{
>> Name = $_.Name
>> Hash = $hash.Hash
>> Algorithm = $hash.Algorithm
>> }
>> }
@ThoenigAdrian
ThoenigAdrian / proc_by_name.py
Last active September 3, 2024 12:32
Search process by name ctypes windows - WAAAAY FASTER THAN psutil psutil.process_iter()
import ctypes
import ctypes.wintypes
# Load the required libraries
psapi = ctypes.WinDLL('Psapi.dll')
kernel32 = ctypes.WinDLL('kernel32.dll')
# Define constants
PROCESS_QUERY_INFORMATION = 0x0400
PROCESS_VM_READ = 0x0010
import torch.nn
import timeit
from torch.nn import Linear
shape = [784, 50, 50, 50, 10]
batch_size = 500
x = torch.rand((500, 784), device="cuda")
y = torch.rand((500, 10), device="cuda")
git filter-branch --tree-filter 'rm -f ai/neat_server/checkpoints/neat-checkpoint-2000' HEAD
float rand_FloatRange(float a, float b)
{
return ((b - a) * ((float)rand() / RAND_MAX)) + a;
}
# https://stackoverflow.com/a/53374933/5130800
import torch
# setting device on GPU if available, else CPU
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
print('Using device:', device)
print()
#Additional Info when using cuda
if device.type == 'cuda':
print(torch.cuda.get_device_name(0))
# Import python packages which are installed in the nix store
# Note you NEED this if you install it via environment.systemPackages
# E.g environment.systemPackages = with pkgs; [ python27Packages.tensorflowWithCuda ]
# You DON'T NEED this if you do it like this:
# python-with-my-packages = pkgs.python27.withPackages (ps: with ps; [ tensorflowWithCuda]);
# environment.systemPackages = [ python-with-my-packages ]
import sys
sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos-unstable
sudo nix-channel --update nixos-unstable
with import <nixpkgs> {};
let
python = python37;
in
pkgs.mkShell {
name = "pip-env";
buildInputs = with pkgs; [
gmp5
libffi
private void TabDefault()
{
// The idea is as a User I expect the Tab Button to go from left to right and from top to bottom.
// Unfortunately this isn't the default behaviour in WinForms hence this method.
// It will go through all Controls and sort them by their x and y coordinates and set a sane set of Tab Indices
// This saves Maintainence because now you don't need to adapt Tab Indices when you add/remove a control
List<Control> tabAbleControls = new List<Control>();
foreach (Control c in Controls)
{
if(c.TabStop)