Skip to content

Instantly share code, notes, and snippets.

@CVertex
CVertex / model_to_release.py
Created October 10, 2016 04:11 — forked from keunwoochoi/model_to_release.py
playlist generation model
import keras
from keras.models import Sequential
from keras.layers.core import Dense, Activation, Dropout, TimeDistributedDense
from keras.layers.recurrent import LSTM, SimpleRNN
def build_model(num_layers=2, num_units=256, maxlen_rnn=50, dim_label=50):
'''
num_layers: in [2, 3]
num_units: in [256, 512, 1024]
@CVertex
CVertex / DeliminatorSeparatedPropertyNamesContractResolver.cs
Created September 24, 2016 12:13 — forked from roryf/DeliminatorSeparatedPropertyNamesContractResolver.cs
Snake case (underscore separated) property name resolver for Newtonsoft.Json library
public class DeliminatorSeparatedPropertyNamesContractResolver : DefaultContractResolver
{
private readonly string _separator;
protected DeliminatorSeparatedPropertyNamesContractResolver(char separator) : base(true)
{
_separator = separator.ToString();
}
protected override string ResolvePropertyName(string propertyName)
@CVertex
CVertex / load_spotify_markets.js
Created September 14, 2016 06:46
Read all Spotify Markets from Spotify Charts
// Visit https://spotifycharts.com/regional and run the following in console
var ts = '';
$('div[data-type=country] ul li').each(function(i,val) {
ts += 'new Market("' + $(val).text() + '","' + $(val).attr("data-value").toUpperCase() + '"),' + " ";
});
console.log(ts);
@CVertex
CVertex / Effects.LinearGradient.cs
Created August 13, 2016 04:48
Linear gradient (left to right) using GDI
public static Bitmap LinearGradient(Image source, Color leftColor, Color rightColor)
{
// Create the gradient
//using (var grad = new )
// Mutate the source
using (Graphics graphics = Graphics.FromImage(source))
{
Rectangle bounds = new Rectangle(0, 0, source.Width, source.Height);
// srcColor:Color, destColor:Color
// We're converting everything to doubles [0,1.0], then performing multiply
// then converting back to byte
// These conversions are slow
var sr = Convert.ToDouble(srcColor.R) / 255.0;
var sg = Convert.ToDouble(srcColor.G) / 255.0;
var sb = Convert.ToDouble(srcColor.B) / 255.0;
@CVertex
CVertex / OverlayWithLinearGradient.cs
Created August 13, 2016 04:05
My first imageprocessor IGraphicsProcessor
public class OverlayWithLinearGradient : IGraphicsProcessor
{
public OverlayWithLinearGradient()
{
this.DynamicParameter = Tuple.Create(Color.PaleVioletRed, Color.CornflowerBlue);
this.Settings = new Dictionary<string, string>();
}
public dynamic DynamicParameter
@CVertex
CVertex / debouncer.js
Created July 7, 2016 06:57 — forked from jasonwyatt/debouncer.js
How to **correctly** debounce an event that will be triggered many times with identical arguments.
function debounce(fn, debounceDuration){
// summary:
// Returns a debounced function that will make sure the given
// function is not triggered too much.
// fn: Function
// Function to debounce.
// debounceDuration: Number
// OPTIONAL. The amount of time in milliseconds for which we
// will debounce the function. (defaults to 100ms)
@CVertex
CVertex / print-ordered-features.js
Created March 10, 2016 22:52
Prints the non-zero features in the console in BigML cluster console
var scores = [];
$('.kluster-fields').find('.numeric').each(function() {
var r = $(this);
var name = r.find('span:first').text().replace(":","");
var val = parseFloat(r.find('strong').text());
//console.log(name + ' ' + val);
var s = {name:name,score:val};
scores.push(s);
});
import UIKit
struct Person {
let name: String
let city: String
}
let people = [
Person(name: "Chris", city: "Berlin"),
Person(name: "Natasha", city: "Tokyo"),
@CVertex
CVertex / extract-testflight.js
Created November 26, 2015 02:00
Extract TestFlight user email addresses from iTunes Connect
var text = '';
$('.itc-tester-view tbody tr').each(function(index, el) {
var email = el.querySelector('td:nth-child(2) span:first-child').innerText;
var name = el.querySelector('.sorted > span').innerText.split(' ');
text = text + name[0] + ', ' + name[1] + ', ' + email+'\n';
});
var a = document.createElement("a");
var file = new Blob([text], {type: 'text/csv'});
a.href = URL.createObjectURL(file);