Skip to content

Instantly share code, notes, and snippets.

@delebedev
delebedev / opena.sh
Created March 19, 2014 13:58
Opens Xcode workspace or project with AppCode.
opena(){
if test -n "$(find . -maxdepth 1 -name '*.xcworkspace' -print -quit)"
then
echo "Opening workspace"
open *.xcworkspace -a /Applications/AppCode.app
return
else
if test -n "$(find . -maxdepth 1 -name '*.xcodeproj' -print -quit)"
then
echo "Opening project"
@delebedev
delebedev / main.swift
Created June 7, 2015 11:09
Export Foursquare checkins to GPX
//
// main.swift
// ForsquareGPX
//
// Created by Dzianis Lebedzeu on 07/06/2015.
// Copyright (c) 2015 Home. All rights reserved.
//
import Foundation
@delebedev
delebedev / gimmeWWDC.rb
Last active August 29, 2015 14:22
Get all fresh WWDC sessions at once
#!/usr/bin/env ruby
require 'net/http'
require 'json'
require 'ostruct'
require 'fileutils'
PATH = "https://devimages.apple.com.edgekey.net/wwdc-services/ftzj8e4h/6rsxhod7fvdtnjnmgsun/videos.json"
WWDC_DIR = "#{Dir.home}/Downloads/wwdc"
@delebedev
delebedev / main.swift
Created April 12, 2016 14:22
Tiny networking revisited
import Result
import Unbox
public enum Method: String { // Bluntly stolen from Alamofire
case OPTIONS = "OPTIONS"
case GET = "GET"
case HEAD = "HEAD"
case POST = "POST"
case PUT = "PUT"
case PATCH = "PATCH"

Types

A type is a collection of possible values. An integer can have values 0, 1, 2, 3, etc.; a boolean can have values true and false. We can imagine any type we like: for example, a HighFive type that allows the values "hi" or 5, but nothing else. It's not a string and it's not an integer; it's its own, separate type.

Statically typed languages constrain variables' types: the programming language might know, for example, that x is an Integer. In that case, the programmer isn't allowed to say x = true; that would be an invalid program. The compiler will refuse to compile it, so we can't even run it.

Adyen Test Card Numbers
These cards are only valid on our TEST system and they will never involve any actual transaction or transfer of funds. The TEST card numbers will not work on the Adyen LIVE Platform.
For all cards use the following expiration and CVV2/CVC2/or CID for Amex.
For all cards:
Expiration Dates CVV2 / CVC3 CID (American Express)
06/2016 OR 08/2018 737 7373
@delebedev
delebedev / xxx.swift
Last active March 17, 2017 15:28
Swift CoreData craziness
// Class Keyword: NSManagedObject is defined in objective-c (not sure if it matters)
// .keywords is CoreData to-many relationship pointing to "Keyword" objects.
// How do I convert .keywords to [Keyword]?
po type(of: keywords)
_NSFaultingMutableOrderedSet
po keywords is NSOrderedSet
true
@delebedev
delebedev / minimal.swift
Created July 2, 2017 10:16 — forked from sjoerdvisscher/minimal.swift
Using Decodable to generate a minimal value
struct MinimalDecoder : Decoder {
var codingPath = [CodingKey?]()
var userInfo = [CodingUserInfoKey : Any]()
public func container<Key>(keyedBy type: Key.Type) throws -> KeyedDecodingContainer<Key> {
return KeyedDecodingContainer(MinimalKeyedDecodingContainer<Key>(decoder: self))
}
public func unkeyedContainer() throws -> UnkeyedDecodingContainer {
return DecodingContainer(decoder: self)
@delebedev
delebedev / curl.py
Last active June 19, 2018 11:31
curl lldb plugin (swift4)
#!/usr/bin/env python
import lldb
def process(debugger, command, result, internal_dict):
lldb.debugger.HandleCommand("""
expr -l swift --
func $process(_ request: URLRequest) {
func curl(_ request: URLRequest) -> String {
guard let url = request.url?.absoluteString else {
@delebedev
delebedev / bs.md
Created May 28, 2019 15:48
javascript hits again

Javascript is fun

a = new Date('2019-03-31T00:00:00.000Z');
a.setDate(a.getDate() + 1);
console.log(a);
Firefox macos Safari macos chrome macos