View gist:78d09c214a0b952262c80b03b7492251
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]): |
View gist:74f9f95b1c67c8403f5c06a22b6239f8
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 |
View gist:1b54c7546da09ff7c9c0aca80d9577d9
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]: |
View gist:2f6db1e1eac0dcff6a0c4f552ba5de98
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 |
View gist:842669d1ab1be9953f8d252824c8c5bc
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 |
View Levenshtein.swift
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 { |
View ViewController.swift
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 | |
} |
View example.js
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) { | |
/* |
View gist:9031785d77ac8b81ca78b8bb57fcf822
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) |
View fat_lib.py
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