Skip to content

Instantly share code, notes, and snippets.

# git clone from https://github.com/tkarras/progressive_growing_of_gans
# download the snapshot from their Google drive
# use the following code in the same directory to generate random faces
import os
import sys
import time
import glob
import shutil
import operator
import theano

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@jsvnm
jsvnm / itunes.rb
Created November 17, 2014 17:00
hooray for rb-appscript
require 'appscript'
require 'titleize'
def set_tags_from_filename(track)
f=track.location.get.path.split('/')[-1]
m=f.match(/(\d\d) (.+?) - (.+?)\.mp3/);
track.track_number.set m[1]
track.artist.set m[2].titleize
track.name.set m[3].titleize
@jsvnm
jsvnm / out-of-the-box.cs
Created March 26, 2013 18:54
Why are the values in a box? come out of there.
private static class Boxed<T> {
internal static readonly Converter<object, T> PleaseComeOut = Boxed<T>.Delivers(typeof(T));
private static Converter<object, T> Delivers(Type type) {
if (type.IsValueType) return new Converter<object, T>(Boxed<T>.Contents);
throw new InvalidOperationException("No thanks");
}
private static T Contents(object value) { return (T) value; }
}
@jsvnm
jsvnm / Hex2InvertedHSL.rb
Created March 4, 2013 14:44
replace #FAABAE colors in css with hsl(1,2,3) style, and invert lightness while doing that
require "color";
class Hex2InvertedHSL
def initialize; @convs={}; end;
def do(line)
line.gsub(/#[0-9a-fA-F]{6}/) { |hex|
@convs[hex] || (@convs[hex]=conv(hex))
}
end
@jsvnm
jsvnm / gist:4737877
Created February 8, 2013 10:08
move to next eol with C-S-e (next-line and then move to end of that if we're already at eol, otherwise just go to end of current line) tried apropos and googled for maybe three minutes then wrote this in one. same functionality probably exists either as part of standard emacs or better implemented by someone with a clue.
(defun move-next-end-of-line (arg)
"if at eol go to next line. in any case go to eol."
(interactive "^p")
(when (eolp)
(next-line))
(move-end-of-line arg))
(global-set-key (kbd "C-S-e") 'move-next-end-of-line)
@jsvnm
jsvnm / LinqToVisualTree.cs
Created December 3, 2012 10:42
bit modified linqtovisualtree
// original from http://www.scottlogic.co.uk/blog/colin/2010/03/linq-to-visual-tree/
using System;
using System.Linq;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Media;
namespace LinqToVisualTree
{
@jsvnm
jsvnm / gist:4087131
Created November 16, 2012 12:56
make local branches that track the ones in remote (origin)
for r in `git branch -r | grep -v HEAD`; do b=${r#origin/}; git branch --track $b $r; done
@jsvnm
jsvnm / rgbFromWavelength.rb
Created November 15, 2012 15:42
get rgb value of wavelength
# from http://www.physics.sfasu.edu/astro/color/spectra.html
def rgbFromWavelength(wl, gamma=0.8)
rgb=case wl
when (380..439); [-1.0*(wl-440.0)/(440.0-380.0), 0.0, 1.0]
when (440..489); [0.0, (wl-440.0)/(490.0-440.0), 1.0]
when (490..509); [0.0, 1.0, -1.0*(wl-510.0)/(510.0-490.0)]
when (510..579); [(wl-510.0)/(580.0-510.0), 1.0, 0.0]
when (580..644); [1.0, -1.0*(wl-645.0)/(645-580.0), 0.0]
when (645..780); [1.0, 0.0, 0.0];