Skip to content

Instantly share code, notes, and snippets.

View vi4m's full-sized avatar
:atom:
coding

✪ vi4m Marcin Kliks vi4m

:atom:
coding
View GitHub Profile
import TokamakShim
import JavaScriptKit
public let window = JSObject.global.window.object!
public let location = JSObject.global.location.object!
struct TokamakApp: App {
var body: some Scene {
WindowGroup("Tokamak App") {
ContentView()
@vi4m
vi4m / keybase.md
Created January 29, 2018 15:13
keybase.md

Keybase proof

I hereby claim:

  • I am vi4m on github.
  • I am vi4m (https://keybase.io/vi4m) on keybase.
  • I have a public key ASCLCcLhtEgffh8mDXgJ86Q_kyPP6wppprdI_MK1madJdwo

To claim this, I am signing this object:

### Keybase proof
I hereby claim:
* I am vi4m on github.
* I am vi4m (https://keybase.io/vi4m) on keybase.
* I have a public key ASCLCcLhtEgffh8mDXgJ86Q_kyPP6wppprdI_MK1madJdwo
To claim this, I am signing this object:
@vi4m
vi4m / asciiwwdc.com
Created December 31, 2016 20:09
single page macos swift app webview wrap of http://asciiwwdc.com
#!/usr/bin/swift -target x86_64-apple-macosx10.12 -v
import Cocoa
import WebKit
func halfWindow(title: String = "Half Window (^c to quit)") -> NSWindow {
let window = NSWindow()
if let screen = window.screen {
var frame = screen.visibleFrame
let size = CGSize(width: frame.size.width / 2, height: frame.size.height)
frame = CGRect(origin: .zero, size: size)
@vi4m
vi4m / request.txt
Created September 17, 2016 20:26
zewo bug - request.txt
HTTP/1.1 200 OK
Date: Fri, 16 Sep 2016 16:23:17 GMT
Connection: close
test
@vi4m
vi4m / zewo.py
Created September 17, 2016 20:25
zewo bug - server.py
#!/usr/bin/env python
"""
Demo Content-Length bug in Zewo
Usage::
./dummy-web-server.py [<port>]
Send a GET request::
curl http://localhost
@vi4m
vi4m / fixer.swift
Last active September 14, 2016 08:30
XCode 7 fix for zewo packages
#!/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-05-31-a.xctoolchain/usr/bin/swift
import Foundation
func currentPath() -> String {
let pathPointer = UnsafeMutablePointer<Int8>(allocatingCapacity: 1024)
defer { pathPointer.deallocateCapacity(1024) }
@vi4m
vi4m / struct_and_inheritance.swift
Created December 28, 2015 12:46 — forked from AliSoftware/struct_vs_inheritance.swift
Swift-Struct-Inheritance
// #!Swift-1.1
import Foundation
// MARK: - (1) classes
// Solution 1:
// - Use classes instead of struct
// Issue: Violate the concept of moving model to the value layer
// http://realm.io/news/andy-matuschak-controlling-complexity/

Write simple Singleton.

Write Singleton which returns the same object every time. You can use the implementation you want.

first_object = Singleton(name='test1')
second_object = Singleton(name='test2')
print(first_object.name == second_object.name)

Beautifull function decorator

Write decorator which prints function arguments and result. When decorated on given function with arbitrary number of arguments, invocation of this function should print-out arguments, and the result.

    @deco
    def sum_(x, y):
        return x + y