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
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 |
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 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) |
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
# 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. |
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
# 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 |
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
# 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 |
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
# 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 |
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
# 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 |
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
# 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 |
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
# | |
# 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 |