In ~/.zshrc
, put the following:
pidportfunction() {
lsof -n -i4TCP:$1 | grep LISTEN
}
alias pidport=pidportfunction
import UIKit | |
import RxSwift | |
class ViewController: UIViewController { | |
private let disposeBag = DisposeBag() | |
private let client = NewsClient() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
client.headlines().subscribe(onSuccess: { (response) in |
// This snippet is a lazy, temporary, inappropriate, not secure fix for error: | |
// | |
// "No 'Access-Control-Allow-Origin' header is present on the requested resource". | |
// | |
// It works as a proxy and add 'Access-Control-Allow-Origin: *' to the response header. | |
// | |
// 1) Init proejct and add dependencies: | |
// | |
// ``` | |
// npm init |
Put this helper funciton in your ~/.zshrc
or ~/.bash_profile
:
release_port() {
pid=$(lsof -ti:$1)
if [ -z $pid ]; then
echo "Nothing is running on port $1"
else
kill $pid
echo "Killed process on port $1 with pid $pid"
PurchaseRequest( | |
itemId: 375, | |
name: "Spook", | |
price: Amount( | |
value: 100, | |
currency: 'USD' | |
), | |
insurancePolicies=[ | |
20931, | |
12035 |
import sublime | |
import sublime_plugin | |
class ExampleCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
self.view.insert(edit, 0, "Hello, World!") |
import sublime | |
import sublime_plugin | |
def format(input): | |
output = "" | |
counter = 0 | |
SPACE = ' ' | |
for char in input: | |
if char in "([{": | |
counter += 1 |
def format(input): | |
... | |
class BracketFormatterCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
whole_region = sublime.Region(0, self.view.size()) | |
text = self.view.substr(sublime.Region(0, self.view.size())) | |
formatted_text = format(text) | |
self.view.replace(edit, whole_region, formatted_text) |
from typing import List | |
import json | |
class Student(object): | |
def __init__(self, first_name: str, last_name: str): | |
self.first_name = first_name | |
self.last_name = last_name | |
@classmethod | |
def from_json(cls, data): |