Skip to content

Instantly share code, notes, and snippets.

bgusach /
Last active July 10, 2024 14:14
Python string multireplacement
def multireplace(string, replacements, ignore_case=False):
Given a string and a replacement map, it returns the replaced string.
:param str string: string to execute replacements on
:param dict replacements: replacement dictionary {value to find: value to replace}
:param bool ignore_case: whether the match should be case insensitive
:rtype: str
bwhite /
Created September 15, 2012 03:23
Ranking Metrics
"""Information Retrieval metrics
Useful Resources:
Learning to Rank for Information Retrieval (Tie-Yan Liu)
import numpy as np
PatrikHlobil /
Last active February 9, 2024 23:29
Get all keys or values of a nested dictionary or list in Python
def iterate_all(iterable, returned="key"):
"""Returns an iterator that returns all keys or values
of a (nested) iterable.
- iterable: <list> or <dictionary>
- returned: <string> "key" or "value"
thomasjk10 /
Last active March 25, 2023 07:25
Following links in python using Beautiful Soup
joewiz / environment-variables.xq
Last active September 25, 2021 12:28
Display all environment variables and their values
xquery version "3.1";
element environment-variables {
for $var in available-environment-variables()
order by $var
element environment-variable {
attribute name { $var },
attribute value { environment-variable($var) }
anonymous / autoML_classification.ipynb
Created February 28, 2018 02:55
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
binaryfoundry /
Created January 30, 2018 15:18
Port of Joel Grus Fizz Buzz in Tensorflow to Keras
from keras.models import Sequential
from keras.layers import Dense
import numpy as np
def binary_encode(i, num_digits):
return np.array([i >> d & 1 for d in range(num_digits)])
shibuiwilliam / keras_fizzbuzz
Created February 11, 2017 12:44
fizzbuzz in Keras
import numpy as np
from keras.models import Sequential
from keras.layers import Dense
from keras.utils import np_utils
from keras.layers import Dense
from keras.models import Model
# create training data
def binary_encode(i, num_digits):