Skip to content

Instantly share code, notes, and snippets.

🤓
Studying

Ferdinand Mütsch n1try

🤓
Studying
Block or report user

Report or block n1try

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@n1try
n1try / matmult.go
Last active Dec 4, 2018
Simple Matrix multiplication and transpostion with Go (https://play.golang.org/p/QyXf-mEDUq)
View matmult.go
/* Simple Matrix multiplication and transpostion with Go */
package main
import (
"fmt"
"errors"
)
func transpose(x [][]float32) [][]float32 {
View aoc_2018_day1.scala
import scala.io.Source
object Advent {
def main(args: Array[String]): Unit = {
val data = Source.fromFile("data/day1.txt").getLines.map(_.toInt).toList
println(f"Part 1: ${data.sum}")
/* Can someone help me get this second part a littler more Scala-like (more functional, less procedural)? Please let me know! */
var seen: Set[Int] = Set()
@n1try
n1try / fetch.js
Created Mar 6, 2017
Get image as base64 string using node-fetch
View fetch.js
'use strict';
const fetch = require('node-fetch')
, base64stream = require('base64-stream');
const URL = 'https://www.google.de/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png';
fetch(URL)
.then((res) => {
return new Promise((resolve, reject) => {
@n1try
n1try / mlp.py
Created Aug 16, 2017
MNIST with Scikit Learn's Multi-Layer Perceptron
View mlp.py
import numpy as np
from scipy.ndimage import convolve
from sklearn.neural_network import MLPClassifier
from sklearn.datasets import fetch_mldata
from sklearn.model_selection import train_test_split, cross_val_score, GridSearchCV
from sklearn.externals import joblib
import os.path
PATH = 'mlp_model.pkl'
View keybase.md

Keybase proof

I hereby claim:

  • I am n1try on github.
  • I am n1try (https://keybase.io/n1try) on keybase.
  • I have a public key ASC6rHe9n814abdoPWWaMVLe1xnDvycokFVY80toj1V2two

To claim this, I am signing this object:

View qcartpole_gridsearch.py
import time
import multiprocessing
import numpy as np
from sklearn.model_selection import ParameterGrid
import qcartpole
N_RUNS = 10
grid_params = {
@n1try
n1try / android_fullheight_gridview.java
Created May 22, 2018
A helper method that enables an Android GridView to be used inside a vertical ScrollView
View android_fullheight_gridview.java
/* Inspired by https://stackoverflow.com/a/27818661/3112139 */
public static void justifyListViewHeightBasedOnChildren (GridView listView) {
ListAdapter adapter = listView.getAdapter();
if (adapter == null) {
return;
}
ViewGroup vg = listView;
int totalHeight = 0;
for (int i = 0; i < adapter.getCount(); i++) {
@n1try
n1try / deezer2json.js
Last active Mar 24, 2018
Export Deezer playlist to JSON
View deezer2json.js
/*
1. Go to Deezer.com and open the playlist you want to export, e.g. https://www.deezer.com/en/profile/850026602/loved
2. Scroll down to the very bottom
3. Open your browser's dev tools (F12 on Linux an Windows) and go to the Console tab
4. Paste the following one-line command and hit enter
*/
JSON.stringify(Array.prototype.slice.call(document.getElementsByClassName('datagrid-row song')).map(r => Object.assign({}, {title: r.getElementsByClassName('title')[0].childNodes[0].textContent, artist: Array.prototype.slice.call(r.querySelectorAll('[itemprop="byArtist"]')).map(a => a.textContent).reduce((acc, a) => a + ', ' + acc, '').slice(0, -2)})), null, 2)
@n1try
n1try / apriori.py
Last active Feb 14, 2018
Naive implementation of the Apriori algorithm in Python
View apriori.py
# Naive implementation of the Apriori algorithm in Python
# Example 2 from https://en.wikipedia.org/wiki/Apriori_algorithm
data = [
{1,2,3,4},
{1,2,4},
{1,2},
{2,3,4},
{2,3},
{3,4},
@n1try
n1try / wsgi.py
Last active Nov 8, 2017
Sample WSGI web server with Flask
View wsgi.py
# gunicorn --bind 0.0.0.0:8000 --workers 4 wsgi:app
# gunicorn --bind 0.0.0.0:8000 --workers 1 --threads 12 wsgi:app
import time
from flask import Flask
app = Flask(__name__)
# Requests from one client are not blocked by long-lasting requests from another client, as long as there are workers available
@app.route('/sleep')
You can’t perform that action at this time.