Skip to content

Instantly share code, notes, and snippets.

View avdyushin's full-sized avatar

Grigory Avdyushin avdyushin

View GitHub Profile
@avdyushin
avdyushin / Stack.swift
Created February 1, 2016 09:03
Stack data structure via linked lists using Swift enums
indirect enum LinkedList<T> {
case Empty
case Node(value: T, next: LinkedList<T>)
init() { self = .Empty }
}
extension LinkedList {
func cons(x: T) -> LinkedList<T> {
return .Node(value: x, next: self)
@avdyushin
avdyushin / storage.swift
Last active August 28, 2023 14:35
CoreData stack for iOS 9 and iOS 10 using Swift 3
//
// Storage.swift
//
// Created by Grigory Avdyushin on 30.06.16.
// Copyright © 2016 Grigory Avdyushin. All rights reserved.
//
import UIKit
import CoreData
@avdyushin
avdyushin / Unix command cheats
Last active July 2, 2022 22:56
Terminal commands cheat list
#
# ZSH, Mac OS X or Ubuntu
#
# Decode base 64 and convert into hex string
echo 'aGI32ansgxzKWh3RV4EjRwQsW1v1la+7NBTdjx8zYq0=' | base64 -D | hexdump -ve '1/1 %.2x' | pbcopy
# Get dirs sizes in one level and sort them
du --max-depth=1 -h | sort -n
@avdyushin
avdyushin / hasPrefix.swift
Last active August 24, 2021 08:15
Swift 4 hasPrefix in switch
let string = "www."
func hasPrefix(_ prefix: String) -> (String) -> Bool {
return { value in value.hasPrefix(prefix) }
}
func ~=(block: (String) -> Bool, string: String) -> Bool {
return block(string)
}
@avdyushin
avdyushin / ASCII.swift
Created February 15, 2016 09:59
Swift Character get ASCII code value
extension Character {
var asciiValue: Int {
get {
let s = String(self).unicodeScalars
return Int(s[s.startIndex].value)
}
}
}
@avdyushin
avdyushin / DisplayLink.swift
Last active June 4, 2019 08:08 — forked from CanTheAlmighty/DisplayLink.swift
DisplayLink for OSX
@avdyushin
avdyushin / convert_books.py
Created April 30, 2019 10:55
Conver Unbound Bible format into SQL
#!/usr/bin/python
import fileinput
version = "kjv"
header = """--
--
--
@avdyushin
avdyushin / UnitTests.swift
Created February 5, 2019 10:44
Unit Tests in Swift Playground
class Tests: XCTestCase {
override func setUp() {
super.setUp()
}
override func tearDown() {
super.tearDown()
}
}
@avdyushin
avdyushin / GIF-Screencast-OSX.md
Created September 19, 2018 08:08 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@avdyushin
avdyushin / reorder_photos.py
Last active June 20, 2018 19:52
Reorder photos by Exif date
#!/usr/bin/python
# coding: utf8
import io
import re
import time
import shutil
import os.path
import hashlib
import argparse