Skip to content

Instantly share code, notes, and snippets.

@varokas
varokas / hangman2.py
Last active September 25, 2018 06:24
hangman ep2
from collections import namedtuple
from enum import Enum
import unittest
Status = Enum('Status', 'in_progress win lose')
Event = namedtuple("Event", "status selectedLetters lifeLeft secretWordLength knownSecretWord")
def reactiveHangman(secretWord, letters):
event = init(secretWord)
for l in letters:
@varokas
varokas / hangman.py
Created September 22, 2018 07:25
Hangman
# User win if all letters in secret_words are used in the guess letters
def hangman(secret_word, letters):
return not( set(secret_word) - set(letters) )
# hangman('bigbears', ['a','e','i','o','u','c','d','p','r','k','l','j','h'])
# >> False
#
# >>> hangman('bigbears', ['a','e','i','b','r','g','s'])
# True
@varokas
varokas / dash.py
Last active July 24, 2018 23:09
Enumerate all services for KPIs in Hubble Dashboard
#!/usr/bin/python
"""
How to Use
==========
1. Copy json content of hubble dashboard to clipboard
1.1 Click on the hamburger menu top right of dashboard
1.2 Select "Edit Dashboard"
1.3 ⌘-A (select all), ⌘-C (copy)
@varokas
varokas / turicreate-examples-04-vision.swift
Created July 1, 2018 07:51
turicreate-examples-04-vision.swift
import UIKit
import CoreML
import Vision
let compiledModelUrl = Bundle.main.url(forResource:"ApplesOranges", withExtension: "mlmodelc")
let model = try MLModel(contentsOf: compiledModelUrl!)
let vnModel = try VNCoreMLModel(for: model)
func classify(_ uiImage: UIImage) throws -> [String]? {
let request = VNCoreMLRequest(model: vnModel)
@varokas
varokas / turicreate-examples-03-train.ipynb
Created July 1, 2018 07:18
turicreate-examples-03-train.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@varokas
varokas / turicreate-examples-02-prepare.py
Created July 1, 2018 07:13
turicreate-examples-02-prepare.py
import turicreate as tc
# There will be a few 'Unexpected JPEG decode failure' ignore those
data = tc.image_analysis.load_images('data/', with_path=True)
# Apple Label column to each data based on whether they have the word 'apple' or 'orange' in path
data['label'] = data['path'].apply(lambda path: 'apple' if '/apples' in path else 'orange')
# Save this information as a frame to use later
data.save('apples-oranges.sframe')
@varokas
varokas / turicreate-examples-01-download.ipynb
Created July 1, 2018 06:53
turicreate-examples-01-download.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
private static final Map<Long, PartitionResult> getPartitionsForUsersPrivate(List<Long> dsids)
throws AccountAPIException {
BatchLookupPartitionRequest batchLookupPartitionRequest = new BatchLookupPartitionRequest();
for (Long dsid : dsids) {
batchLookupPartitionRequest.addDsidServiceTypePair(dsid, ServiceType.CloudDB);
}
BatchPartitionResponse batchPartitionResponse =
PartitionAssignmentAPIFactory.partitionAssignmentAPI().batchLookupDatastore(
batchLookupPartitionRequest);
@varokas
varokas / error
Created June 12, 2018 08:11
node error
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\Programmer\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Programmer\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Programmer\Desktop\Toursystem\apiweb\node_modules\node-jasper\node_modules\java
gyp ERR! node -v v8.11.2
@varokas
varokas / Tasks.java
Last active June 9, 2018 04:16
tasks
//
class UI {
List<ProgressBar> progressBars;
public void updateProgress(int taskNumber, int pct) {
progressBars.get(0).setTaskPercent(pct)
}
}
task1 = new Task(ui) {