Skip to content

Instantly share code, notes, and snippets.

View delijati's full-sized avatar

Josip Delić delijati

  • Potsdam (Berlin)
View GitHub Profile
@leplatrem
leplatrem / simple.py
Last active October 12, 2023 11:33
Batched producer/consumer
import asyncio
import async_timeout
import concurrent.futures
import random
import time
async def produce(queue, n):
for x in range(n):
# produce an item
@impredicative
impredicative / logger.py
Last active March 11, 2023 10:59
Python json logging using structlog and stdlib logging
"""
Usage example:
from logger import get_logger
log = get_logger()
log.info('my_event', my_key1='val 1', my_key2=5, my_key3=[1, 2, 3], my_key4={'a': 1, 'b': 2})
List of metadata keys in each log message:
event
_func
@jaantollander
jaantollander / decorator.py
Last active December 30, 2023 21:50
Template for Python decorator function and class
import functools
def decorator(function):
"""A general decorator function"""
@functools.wraps(function)
def wrapper(*args, **kwargs):
# Write decorator function logic here
# Before function call
#!/bin/bash
iatest=$(expr index "$-" i)
#######################################################
# SOURCED ALIAS'S AND SCRIPTS BY zachbrowne.me
#######################################################
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc

A Few Useful Things to Know about Machine Learning

The paper presents some key lessons and "folk wisdom" that machine learning researchers and practitioners have learnt from experience and which are hard to find in textbooks.

1. Learning = Representation + Evaluation + Optimization

All machine learning algorithms have three components:

  • Representation for a learner is the set if classifiers/functions that can be possibly learnt. This set is called hypothesis space. If a function is not in hypothesis space, it can not be learnt.
  • Evaluation function tells how good the machine learning model is.
  • Optimisation is the method to search for the most optimal learning model.
javascript: (function (){ var scripts = document.getElementsByTagName('script'); var friendsList; for (var i = 0; i < scripts.length; i++) { var script = scripts[i]; if (script.innerHTML.indexOf('InitialChatFriendsList') > -1) { var friendsListString = script.innerHTML.split('"InitialChatFriendsList",[],{"list":')[1].split(',"groups"')[0]; friendsList = JSON.parse(friendsListString); console.log('friendsList:', friendsList); break; } } var html = friendsList.map(function(id, i){ id = id = id.split('-')[0]; var url = 'http://graph.facebook.com/' + id + '/picture?type=normal'; return '<a target="_blank" href="https://www.facebook.com/' + id + '"><img src="' + url + '"></a>'; }).join('\n'); var css = '<style> a { display: inline-block; margin: 7px; } img { max-width: 70px; max-height: 70px; vertical-align: top; } </style>'; open('data:text/html, <html>' + css + html + '</html>'); }());
@jarutis
jarutis / ubuntu.sh
Last active November 9, 2020 09:01
Theano and Keras setup on ubuntu with OpenCL on AMD card
## install Catalyst proprietary
sudo ntfsfix /dev/sda2
sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.BAK
sudo apt-get remove --purge fglrx*
sudo apt-get install linux-headers-generic
sudo apt-get install fglrx xvba-va-driver libva-glx1 libva-egl1 vainfo
sudo amdconfig --initial
## install build essentials
sudo apt-get install cmake
@KartikTalwar
KartikTalwar / Documentation.md
Last active April 13, 2024 23:09
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
@mavc
mavc / json_parser.py
Created October 1, 2012 18:46
pyparsing and ply demonstration
import re
from ply import lex, yacc
from ply.lex import TOKEN
import pyparsing as pp
# First, let's define a pyparsing parser for JSON.
class JSONPyParsing(object):
# pylint: disable-msg=W0104,E0213
@UniIsland
UniIsland / SimpleHTTPServerWithUpload.py
Created August 14, 2012 04:01
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""