This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
import json | |
import urllib.request | |
def send_data(url: str, sid, pknnmb, timestamp: datetime, baseline, stddev, measures): | |
payload = { | |
'sid': str(sid), | |
'pknmb': str(pknnmb), | |
'timestamp': timestamp.strftime('%Y-%m-%d %H:%M:%S'), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import os | |
def change_install_name(lib_install_path: str): | |
def get_name_map(dir_path: str): | |
files = {} | |
for file in os.listdir(dir): | |
if file.endswith('.dylib') and not os.path.islink(dir_path+'/'+file): | |
files[file.split('.')[0]] = file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import distutils.dir_util | |
import os | |
def generate_fat_libs(root: str, archs: [str], output: str): | |
def get_lib_names(dir: str) -> [str]: | |
libs = [] | |
for file in os.listdir(dir): | |
if file.endswith('.dylib') and not os.path.islink(dir + '/' + file): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func configSearchMenu() { | |
let clear = NSMenuItem(title: "Clear", action: nil, keyEquivalent: "") | |
clear.tag = Int(NSSearchFieldClearRecentsMenuItemTag) | |
searchMenu.insertItem(clear, at: 0) | |
searchMenu.insertItem(NSMenuItem.separator(), at: 0) | |
let recents = NSMenuItem(title: "", action: nil, keyEquivalent: "") | |
recents.tag = Int(NSSearchFieldRecentsMenuItemTag) | |
searchMenu.insertItem(recents, at: 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function TableOfContents () { | |
this.getSections = function() { | |
/* | |
- return an array of section objects | |
- in case there there is no table of content, return an empty array | |
*/ | |
} | |
this.scrollToSection = function(index: number) { | |
/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewController { | |
let button = UIBarButtonItem(barButtonSystemItem: .add, target: nil, action: nil) | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let searchBar = UISearchBar() | |
searchBar.searchBarStyle = .minimal | |
navigationItem.titleView = searchBar | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Levenshtein { | |
private(set) var cache = [Set<String.SubSequence>: Int]() | |
func calculateDistance(a: String.SubSequence, b: String.SubSequence) -> Int { | |
let key = Set([a, b]) | |
if let distance = cache[key] { | |
return distance | |
} else { | |
let distance: Int = { | |
if a.count == 0 || b.count == 0 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// InteractiveController.swift | |
// iOS | |
// | |
// Created by Chris Li on 1/22/18. | |
// Copyright © 2018 Chris Li. All rights reserved. | |
// | |
import UIKit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.raywenderlich.com/139277/uipresentationcontroller-tutorial-getting-started | |
// PanelViewController.swift | |
// iOS | |
// | |
// Created by Chris Li on 1/23/18. | |
// Copyright © 2018 Chris Li. All rights reserved. | |
// | |
import UIKit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(venv) Chriss-MacBook-Pro:worker chrisli$ python worker | |
========================================================= | |
Welcome to Zimfarm worker: | |
========================================================= | |
Let's check some settings: | |
* current values are in '[]' | |
* accept current values by pressing enter | |
Username [admin]: |