Skip to content

Instantly share code, notes, and snippets.

View tomkowz's full-sized avatar

Tomasz Szulc tomkowz

View GitHub Profile
import numpy as np
import time
def loss_i(x_i, y, W):
delta = 1
scores_i = np.dot(W, x_i)
margin = 0
for j in range(scores_i.shape[0]):
if j == y:
@tomkowz
tomkowz / custom-stirng-convertible.swift
Last active January 19, 2018 10:20
CustomStringConvertible
struct Position {
var x: Int = 0
var y: Int = 0
func string() -> String {
return "(\(x), \(y))"
}
}
// CustomStringConvertible provides "description" property.
std::vector<SourceFile*> static_files = this->_source.static_files();
for (auto it_file = static_files.begin(); it_file != static_files.end(); ++it_file) {
// for (auto it_file = this->_source.static_files().begin(); it_file != this->_source.static_files().end(); ++it_file) {
@tomkowz
tomkowz / AsyncBlockOperation.swift
Created May 9, 2017 06:48
Asynchronous NSBlockOperation
import Foundation
class AsyncBlockOperation: NSOperation {
typealias Block = (Void -> Void) -> Void
private let block: Block
private var _executing = false
private var _finished = false
init(block: Block) {