Skip to content

Instantly share code, notes, and snippets.

View JoshBroomberg's full-sized avatar

Josh Broomberg JoshBroomberg

View GitHub Profile
//
// UserManager.swift
// OnboardingApp
//
// Created by Josh Broomberg on 2016/05/28.
// Copyright © 2016 iXperience. All rights reserved.
//
import Foundation
@JoshBroomberg
JoshBroomberg / UITableViewRowAction.swift
Created June 13, 2016 11:26
Code for adding custom TableRowActions to swift tables.
func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
return //return something that makes sense here.
}
// This is a generic implementation of the table data source method for adding row actions.
// Adapt it to match your needs.
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
let action1 = UITableViewRowAction(style: .Normal, title: "Action 1") { action, index in
print("Action 1 tapped")
npm WARN package.json minerva-schools@0.1.0 No repository field.
npm WARN package.json minerva-schools@0.1.0 No license field.
npm WARN deprecated URIjs@1.16.1: package renamed to "urijs" (lower-case), please update accordingly
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated graceful-fs@1.2.3: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch@1.0.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN optional dep failed, continuing fsevents@1.0.14
import random
import numpy as np
a_weight = random.random()
b_weight = random.random()
bias_weight = random.random()
learning_constant = 1
valid_data = [(0,0,-1), (0,1,-1), (1,0,-1), (1,1,1)]
import random
import numpy as np
import matplotlib.pyplot as plt
a_weight = random.random()
b_weight = random.random()
bias_weight = random.random()
weights = {"a": np.array([[0, a_weight]]), "b": np.array([[0, b_weight]]), "bias": np.array([[0, bias_weight]])}
learning_constant = 0.5
logical_function_to_model = raw_input("Develop a perceptron for what logical operator? (and/or)\n")
import random
import math
from collections import defaultdict
import os
import numpy as np
import textwrap
import sys
class Chromosome:
gene_dict = {
@JoshBroomberg
JoshBroomberg / encoding.swift
Created May 23, 2017 19:00
Swift: encode non-ascii characters as utf8 hex
import Foundation
extension Character {
var asciiValue: UInt32? {
return String(self).unicodeScalars.filter{$0.isASCII}.first?.value
}
}
func encodeNonASCIIAsUTF8Hex(toEncode: String) -> String{
var result = ""
@celery.task
def async_training_task(data_file_name, k_iterations):
train_model(file=data_file_name, iterations=k_iterations)
# This is the standard flask handler.
# Maybe you get some params from the request/
def get(self, request):
async_training_task.delay(data_file_name=request.file_name, iterations=10)
return Response("Training has been started!")
#!/usr/bin/env python
# -*- coding: utf-8 -*-
######################
# Speech recognition #
######################
# 1. Work through the following resources:
# Viterbi algorithm. (n.d.). In Wikipedia. Retrieved November 9, 2016, from
# https://en.wikipedia.org/wiki/Viterbi_algorithm
# The 44 Phonemes in English. (n.d.). Retrieved November 9, 2016, from
# http://www.dyslexia-reading-well.com/44-phonemes-in-english.html
compressed_image_data_train = pca.transform(image_data_train)
uncompressed_image_data_train = pca.inverse_transform(compressed_image_data_train)
fig=plt.figure(figsize=(12, 20))
columns = 4
rows = 8
for i in range(1, 33, 4):
component_id = int(i/4)
eigen_image = image_from_component_values(pca.components_[component_id])
inverted_egein_image = PIL.ImageOps.invert(eigen_image)