This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from numpy import array, dot, exp, random | |
training_set_inputs = array([[0, 0, 1], [1, 1, 1], [1, 0, 1], [0, 1, 1]]) | |
training_set_outputs = array([[0, 1, 1, 0]]).T | |
rng = random.default_rng(1) | |
synaptic_weights = 2 * rng.random((3, 1)) - 1 | |
for _ in range(10000): | |
output = 1 / (1 + exp((dot(-training_set_inputs, synaptic_weights)))) | |
synaptic_weights += dot(training_set_inputs.T, (training_set_outputs - output) * output * (1 - output)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Category = { | |
title: string; | |
items: Array<{ name: string }>; | |
}; | |
type Config = { | |
categories: Record<string, Category>; | |
}; | |
function isCategory(obj: unknown): obj is Category { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> from enum import EnumMeta, Enum | |
>>> Color3 = EnumMeta('Color3', (Enum,), (_ := EnumMeta.__prepare__( | |
... 'Color3', (Enum,),)) and any(map(_.__setitem__, *(zip(*{ | |
... 'RED': 1, | |
... 'GREEN': 2, | |
... 'BLUE': 3, | |
... }.items())))) or _ | |
... ) | |
>>> print(Color3(1)) # or without print(): <Color3.RED: 1> | |
Color3.RED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Wordwrap text to a specified line length. | |
Takes a string or file-like object as input and returns the wrapped text. | |
""" | |
import re | |
from typing import IO, Union | |
def wordwrap(text_or_file: Union[str, IO], max_line_length: int = 80) -> str: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def StrToBrf(v: str) -> str: | |
result = [] | |
current = 0 | |
for ch in v: | |
target = ord(ch) | |
diff = target - current | |
if diff > 0: | |
result.append('+' * diff) | |
elif diff < 0: | |
result.append('-' * abs(diff)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set interface INTERFACE_AX | |
set streams 4 | |
set bandwidth BANDWIDTH_ADAPT | |
set vstaCount 1 | |
set vstaConfig {{"interface_": "$interface", "txAtten": 0, "streams": $streams, "bandwidth": "$bandwidth"}} | |
set vstaConfig [subst -nocommands -nobackslashes $vstaConfig] | |
set vsta_array [lrepeat $vstaCount $vstaConfig] | |
set vsta_array [join $vsta_array ", "] | |
puts $vsta_array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
WordBomb.py | |
~~~~~~~~~~~ | |
A simple script to open notepad and type words that contain a given letter. | |
Closes notepad when user wants to stop, without saving the file. | |
Requirements: | |
- Python 3.8 or higher | |
- pyautogui (python3 -m pip install pyautogui) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-Type -assemblyName System.Windows.Forms;$a=@(1..100);$chars="abc";while($true){$c=[System.Windows.Forms.Cursor]::Position;Start-Sleep -Seconds 5;if($c -eq $([System.Windows.Forms.Cursor]::Position)){$randomX=$a|Get-Random;$randomY=$a|Get-Random;$newPosition=New-Object System.Drawing.Point($randomX,$randomY);[System.Windows.Forms.Cursor]::Position=$newPosition;$randomChar=($chars.ToCharArray()|Get-Random -Count $chars.Length)-join"";[System.Windows.Forms.SendKeys]::SendWait($randomChar);$backspaces="{0}"-f('{BACKSPACE}'*$randomChar.Length);[System.Windows.Forms.SendKeys]::SendWait($backspaces)}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable @typescript-eslint/no-var-requires */ | |
/** | |
* @fileoverview | |
* This script is used to fix the import paths in the JS files in the dist directory. | |
* It is used to fix the import paths in the JS files after the build process for tsc. | |
* That way you can then run `node dist/index.js` and the imports will work as expected! | |
* It is recursive, so it will fix all JS files in the directory and its subdirectories. | |
* e.g. | |
* import { someFunction } from '../../someModule'; | |
* will be replaced with |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . -print | sed -e "s;[^/]*/;|____;g;s;____|; |;g" |
NewerOlder