This file contains 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 Solution: | |
def asteroidCollision(self, asteroids): | |
stack = [] | |
for asteroid in asteroids: | |
stack.append(asteroid) | |
while(len(stack) >= 2): | |
if stack[-2] > 0 and stack[-1] < 0: | |
if abs(stack[-2]) > abs(stack[-1]): | |
stack.pop() | |
elif abs(stack[-2]) < abs(stack[-1]): |
This file contains 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
Unable to download content [1] https://ta.wikipedia.org/w/api.php?action=query&list=backlinks&blfilterredir=redirects&bllimit=max&format=json&bltitle=அகடம்_(திரைப்படம்)&rawcontinue= (statusCode=429). | |
Unable to download content [1] https://ta.wikipedia.org/w/api.php?action=query&list=backlinks&blfilterredir=redirects&bllimit=max&format=json&bltitle=அ_(கன்னடம்)&rawcontinue= (statusCode=429). | |
Unable to download content [1] https://ta.wikipedia.org/w/api.php?action=query&list=backlinks&blfilterredir=redirects&bllimit=max&format=json&bltitle=அகரமேறிய_மெய்_முறைமை&rawcontinue= (statusCode=429). | |
Unable to download content [1] https://ta.wikipedia.org/w/api.php?action=query&list=backlinks&blfilterredir=redirects&bllimit=max&format=json&bltitle=அகத்திய_நூற்பட்டியல்&rawcontinue= (statusCode=429). | |
Unable to download content [1] https://ta.wikipedia.org/w/api.php?action=query&list=backlinks&blfilterredir=redirects&bllimit=max&format=json&bltitle=அ._சவுந்திரராசன்&rawcontinue= (statusCode=429). | |
Unable to download content [1 |
This file contains 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]: |
This file contains 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 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 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 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 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 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 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): |
NewerOlder