Skip to content

Instantly share code, notes, and snippets.

View robbdimitrov's full-sized avatar

Robert Dimitrov robbdimitrov

View GitHub Profile
def convert(graph, start, end, path=None):
if path is None:
path = []
if start == end:
return 1
for child in graph[start]:
if child[0] not in path:
result = convert(graph, child[0], end, path + [child[0]])
@robbdimitrov
robbdimitrov / converter.py
Created July 20, 2019 12:05
Simple script converting Android xml localization files to iOS strings
// License: MIT
from xml.etree import ElementTree
import os
def parse_file(xml_file):
filename = xml_file.strip('.xml')
strings_file = open(f'{filename}.strings', 'w')
@robbdimitrov
robbdimitrov / keybindings.json
Last active March 15, 2022 16:31
Visual Studio Code settings
[
{
"key": "shift+enter",
"command": "workbench.action.terminal.findPrevious",
"when": "terminalFindFocused && terminalProcessSupported"
},
{
"key": "enter",
"command": "workbench.action.terminal.findNext",
"when": "terminalFindFocused && terminalProcessSupported"
@robbdimitrov
robbdimitrov / style-guide.md
Last active May 24, 2019 18:16
Style guide

Style guide

Quotes

Use single quotes for Python, JS, SQL and CSS
Use double quotes for everything else

File and directory naming conventions

Folders

@robbdimitrov
robbdimitrov / cors.js
Last active June 23, 2019 12:41
CORS in Expressjs
export class Server {
enableCors() {
this.app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'Origin,Authorization,X-Requested-With,X-Access-Token,Content-Type,Accept');
next();
});
}
}
@robbdimitrov
robbdimitrov / postgres-cheatsheet.md
Last active August 27, 2023 17:39
Postgres Cheatsheet

Pull Postgres

$ docker pull postgres

Create a directory for db persistence

$ mkdir -p [db-volume-location-on-machine]
@robbdimitrov
robbdimitrov / placeholder.js
Last active March 1, 2019 05:34
Placeholder drawing with canvas
// License: MIT
function drawAvatar(name, size) {
let canvas = document.createElement('canvas');
canvas.width = size;
canvas.height = size;
let context = canvas.getContext('2d');
context.fillStyle = '#F8F9F8';
@robbdimitrov
robbdimitrov / ViewStore.swift
Last active April 18, 2019 18:15
Dequeable store for UIViews
// License: MIT
import UIKit
class ViewStore<T: UIView> {
private var views = [T]()
deinit {
flush()
@robbdimitrov
robbdimitrov / BaseCoordinator.swift
Created February 13, 2019 12:27
iOS Coordinators
// LICENSE: MIT
import Foundation
protocol Coordinator {
func start()
}
//
// License: MIT
//
class RepeatingTimer {
private var maxInterval: Float
private var currentInterval: Float = 0
private var timeInterval: TimeInterval