Skip to content

Instantly share code, notes, and snippets.

View automactic's full-sized avatar

ChrisLi automactic

View GitHub Profile
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]):
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
(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]:
@automactic
automactic / gist:2f6db1e1eac0dcff6a0c4f552ba5de98
Created January 24, 2018 16:28
Interactiva Controller with Custom Presentation
// 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
@automactic
automactic / gist:842669d1ab1be9953f8d252824c8c5bc
Created January 24, 2018 04:18
Interactive Controller Experiments
//
// InteractiveController.swift
// iOS
//
// Created by Chris Li on 1/22/18.
// Copyright © 2018 Chris Li. All rights reserved.
//
import UIKit
@automactic
automactic / Levenshtein.swift
Created January 17, 2018 22:13
Levenshtein distance in swift 4
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 {
@automactic
automactic / ViewController.swift
Created January 10, 2018 02:14
Broken iOS 11 NavigationBar
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
}
@automactic
automactic / example.js
Created October 18, 2017 14:21
js in zim
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) {
/*
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)
@automactic
automactic / fat_lib.py
Last active August 16, 2017 21:56
fat_lib.py
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):