Skip to content

Instantly share code, notes, and snippets.

View MarkNenadov's full-sized avatar

Mark Nenadov MarkNenadov

View GitHub Profile
@MarkNenadov
MarkNenadov / binarySearch.kt
Created October 25, 2023 12:50
Kotlin Integer Binary Search
fun binarySearch(numbers: List<Int>, number: Int): Int {
var leftIndex = 0
var rightIndex = numbers.size - 1
while(leftIndex <= rightIndex) {
val midIndex = (leftIndex + rightIndex) / 2
val midNumber = numbers[midIndex];
when {
midNumber == number -> return midIndex
@MarkNenadov
MarkNenadov / gist:d9380a242e0e8257d98524815c738ccb
Created October 24, 2023 11:59
ruby recursive image tally
def image_file?(file, accepted_extensions)
accepted_extensions.include?(File.extname(file).downcase)
end
def recursive_image_tally(directory, image_counts)
image_count = 0
Dir.foreach(directory) do |file|
next if file.start_with?('.')
file_path = File.join(directory, file)
@MarkNenadov
MarkNenadov / wxNotebookPanels.py
Created March 11, 2011 17:07
A Demonstration of how to use a wxPython "Notebook" with panels (WARNING: old code)
# A demonstration of how to use a wxPython "Notebook" with panels
#
# Warning #1: This is a demonstration of how to do a particular thing in wxPython, it is not fully functioning code,
# you need to quite literally "fill in the dots"
#
# Warning #2: This is very old code. I can't guarantee it will work with newer version of Python or wxPython,
# this is 9 year old code!
#
# Note: This example assumes that you have files named panel1.py, panel2.py, panel3.py which contain a "runPanel"
# function which basically returns a wxPanel object.
@MarkNenadov
MarkNenadov / ciphering_idea.py
Created March 8, 2011 21:08
Some throwaway code I used to demonstrate the IDEA cipher with the PyCrypto library
# Sample code by Mark Nenadov.
#
# Warning, this is OLD legacy code. It hasn't been tested in semi recent versions
# of Python or PyCrypto.
#
# You may use this however you wish, but I retain no responsibility whatsoever for how
# you use it and provide it with no warranty, either.
from Crypto.Cipher import IDEA
@MarkNenadov
MarkNenadov / ciphering_rc5.py
Created March 8, 2011 21:07
Some throwaway code I used to demonstrate the RC5 cipher with the PyCrypto library
# Sample code by Mark Nenadov.
#
# Warning, this is OLD legacy code. It hasn't been tested in semi recent versions
# of Python or PyCrypto.
#
# You may use this however you wish, but I retain no responsibility whatsoever for how
# you use it and provide it with no warranty, either.
from Crypto.Cipher import RC5
@MarkNenadov
MarkNenadov / ciperhing_des3.py
Created March 8, 2011 21:04
Some throwaway code I used to demonstrate the DES3 cipher with the PyCrypto library
# Sample code by Mark Nenadov.
#
# Warning, this is OLD legacy code. It hasn't been tested in semi recent versions
# of Python or PyCrypto.
#
# You may use this however you wish, but I retain no responsibility whatsoever for how
# you use it and provide it with no warranty, either.
from Crypto.Cipher import DES3
@MarkNenadov
MarkNenadov / ciphering_des.py
Created March 8, 2011 21:00
Some throwaway code I used to demonstrate the DES cipher with the PyCrypto library
# Sample code by Mark Nenadov.
#
# Warning, this is OLD legacy code. It hasn't been tested in semi recent versions
# of Python or PyCrypto.
#
# You may use this however you wish, but I retain no responsibility whatsoever for how
# you use it and provide it with no warranty, either.
from Crypto.Cipher import DES
@MarkNenadov
MarkNenadov / ciphering_blowfish.py
Created March 8, 2011 21:00
Some throwaway code I used to demonstrate the blowfish cipher with the PyCrypto library
# Sample code by Mark Nenadov.
#
# Warning, this is OLD legacy code. It hasn't been tested in semi recent versions
# of Python or PyCrypto.
#
# You may use this however you wish, but I retain no responsibility whatsoever for how
# you use it and provide it with no warranty, either.
from Crypto.Cipher import Blowfish
@MarkNenadov
MarkNenadov / anagram.py
Created March 8, 2011 20:49
Anagram Fetcher (WARNING: obsolete code)
#
# Anagram Fetcher
#
# NOTE: This is an old, historical script, just posted from my archives for fun. Was
# written to a quite old version of Python. Worked at least up to Python 2.3.4,
# but no longer works in newer versons such as 2.6 and beyond! It silently fails
# in 2.6 and 2.7 and crashes and burns with syntax errors in 3.1
#
# This utility generates a list of anagrams out of a word dictionary. The word
# dictionary is simply a text file containing a list of words with new lines in