Skip to content

Instantly share code, notes, and snippets.

@elgehelge
elgehelge / wikipedia_api__query_all_from_category
Created February 10, 2015 16:42
Efficiently query all articles from a category on Wikipedia (using Python)
import requests
parameters = {'action': 'query',
'generator': 'categorymembers',
'gcmtitle': 'Category:Marvel_Comics_superheroes',
'prop': 'revisions',
'rvprop': 'content',
# The API starts returning dictionaries without the 'revisions' key when requesting more than 50.
# Not sure why, and can't find any documentation.
'gcmlimit': 50,
@elgehelge
elgehelge / DTU globalproxy bookmark
Created April 24, 2015 15:22
Get access to all academic articles as a DTU student
// Step 1: Put this code in a bookmark.
// Step 2: Click the bookmark everytime you need access to an academic article.
// Step 3: Profit!?
javascript: var a=window.location+''; var x=a.indexOf('//'); var p; if(x == -1) { p = a.indexOf('/'); } else { p = a.indexOf('/',x+2); } window.location = a.substring(0,p)+".globalproxy.cvt.dk"+a.substring(p);
import requests
data = {
'apikey' : "9a128231f9bd4d82ac7d28cc74bde19d”,
'user_data': {
'name' : "John Doe",
'email' : "johndoe@gmail.com”
'address' : "123 John st. 12345 Doe”
'phone' : "12345678”
'device ID' : "12345ab6cde789f”

Keybase proof

I hereby claim:

  • I am elgehelge on github.
  • I am elgehelge (https://keybase.io/elgehelge) on keybase.
  • I have a public key ASBPGJHydoH7L_5-JDHSCzpS8YgiMCVM2eG4e_-9TQ8arAo

To claim this, I am signing this object:

@elgehelge
elgehelge / osx_install.sh
Last active July 18, 2023 09:22 — forked from t-io/osx_install.sh
Install most of my apps with homebrew & cask
#!/bin/sh
# Next time I find myself running this, it is time to upgrade and get some inspiration: https://medium.com/@webprolific/getting-started-with-dotfiles-43c3602fd789
# Show hidden files
defaults write com.apple.finder AppleShowAllFiles YES
# Homebrew (cask included)
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@elgehelge
elgehelge / mnist_estimator.py
Last active May 22, 2022 21:43 — forked from peterroelants/mnist_estimator.py
Example using TensorFlow Estimator, Experiment & Dataset on MNIST data.
"""Script to illustrate usage of tf.estimator.Estimator in TF v1.5"""
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data as mnist_data
from tensorflow.contrib import slim
# Show debugging output
tf.logging.set_verbosity(tf.logging.DEBUG)
# Set default flags for the output directories
@elgehelge
elgehelge / mnist_inference.py
Last active January 30, 2018 15:37 — forked from peterroelants/mnist_inference.py
Mnist Inference
"""Script to illustrate inference of a trained tf.estimator.Estimator.
NOTE: This is dependent on mnist_estimator.py which defines the model.
mnist_estimator.py can be found at:
https://gist.github.com/elgehelge/faf200e2b36edfb1b1a77ec65f74ecab
"""
import numpy as np
import skimage.io
import tensorflow as tf
from mnist_estimator import get_estimator
@elgehelge
elgehelge / test_external_generator_error.py
Last active June 23, 2019 23:27
Minimal example - tensorflow with external generator
import tensorflow as tf
# Data source
def data_generator(start, end):
for x, y in zip(range(start, end), range(start, end)):
print(x, y)
yield x, y
@elgehelge
elgehelge / minimal keras training from generator example
Last active July 20, 2021 10:43
Keras + generator, Minimal example
import numpy as np
import tensorflow as tf
from tensorflow.keras import Sequential
from tensorflow.keras.layers import Dense
batch_size = 1
data_size = 1
def generator():
@elgehelge
elgehelge / login_aws_mfa.sh
Last active September 6, 2021 14:56
Bash script for logging into AWS with MFA (and into ECR)
#!/bin/bash
# Usage: `source login_aws_mfa.sh <account id> <name> <mfa code>`
# Example: `source login_aws_mfa.sh 454099695756 john 123456`
{
AWS_ACCESS_KEY_ID= && \
AWS_SECRET_ACCESS_KEY= && \
AWS_SESSION_TOKEN= && \
token=$(aws sts get-session-token --serial-number arn:aws:iam::$1:mfa/$2 --token-code $3) && \