Skip to content

Instantly share code, notes, and snippets.

View HighKo's full-sized avatar

Heiko Guckes HighKo

View GitHub Profile
def reflect_pad(x, width, batch_ndim=1):
"""
Pad a tensor with a constant value.
Parameters
----------
x : tensor
width : int, iterable of int, or iterable of tuple
Padding width. If an int, pads each axis symmetrically with the same
amount in the beginning and end. If an iterable of int, defines the
symmetric padding width separately for each axis. If an iterable of
@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
@ebenolson
ebenolson / draw_net.py
Created March 27, 2015 23:01
Functions to draw Lasagne networks with graphviz, like Caffe's draw_net.py
"""
Functions to create network diagrams from a list of Layers.
Examples:
Draw a minimal diagram to a pdf file:
layers = lasagne.layers.get_all_layers(output_layer)
draw_to_file(layers, 'network.pdf', output_shape=False)
Draw a verbose diagram in an IPython notebook:
@peeblesjs
peeblesjs / gist:9288f79322ed3119ece4
Last active February 11, 2016 23:31
A naive "valueForKey:" operator in Swift
operator infix --> {}
func --> (instance: Any, key: String) -> Any? {
let mirror = reflect(instance)
for index in 0 ..< mirror.count {
let (childKey, childMirror) = mirror[index]
if childKey == key {
return childMirror.value
}
}
@shto
shto / NSManagedObject+Cloner.h
Last active April 20, 2018 04:53
NSManagedObject cloner files
#import <CoreData/CoreData.h>
@interface NSManagedObject (Cloner)
- (NSManagedObject *)clone;
- (NSManagedObject *)cloneInContext:(NSManagedObjectContext *)differentContext;
@end
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active May 17, 2024 12:37
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@steipete
steipete / PSPDFUIKitMainThreadGuard.m
Last active March 10, 2024 19:23
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>
@mikeash
mikeash / gist:1355671
Created November 10, 2011 18:28
Multiple return
// clang -W -Wall -Wno-unused-parameter -framework Foundation -fobjc-arc test.m
#import <Foundation/Foundation.h>
#define IDARRAY(...) ((id[]){ __VA_ARGS__ })
#define IDCOUNT(...) (sizeof(IDARRAY(__VA_ARGS__)) / sizeof(id))
typedef id (^Tuple)(int);