Skip to content

Instantly share code, notes, and snippets.

Ankit Aggarwal aciidb0mb3r

View GitHub Profile
View wat.swift
import Foundation
struct StringCodingKey: CodingKey {
var stringValue: String
init(stringValue: String) {
self.stringValue = stringValue
}
var intValue: Int? { return nil }
init?(intValue: Int) { fatalError() }
}
@aciidb0mb3r
aciidb0mb3r / server.py
Created Oct 15, 2016
Python multithreaded server
View server.py
#! /usr/bin/env python
# Standard library imports.
from SocketServer import ThreadingMixIn
import BaseHTTPServer
import SimpleHTTPServer
import sys
import json
import os
from os.path import (join, exists, dirname, abspath, isabs, sep, walk, splitext,
View faketoolchain.sh
#!/bin/sh
set -e
NINJA_RELEASE_ASSERT_DIR="${HOME}/Documents/workspaces/xcode/github/apple/build/Ninja-ReleaseAssert"
SOURCE_ROOT="${HOME}/Documents/workspaces/xcode/github/apple"
echo "Updating sources (except SwiftPM)"
${SOURCE_ROOT}/swift/utils/update-checkout --skip-repository swiftpm
echo "Done updating sources"
View Term.swift
protocol DumbTerminalProtocol {
func write(_ string: String)
func endLine()
func flush()
}
protocol RichTerminalProtocol: DumbTerminalProtocol {
var width: Int { get }
func clearLine()
func moveCursor(y: Int)
View .py
import json
import os
import pipes
import subprocess
import sys
import lit.Test
import lit.TestRunner
import lit.formats.base
@aciidb0mb3r
aciidb0mb3r / make-toolchain.sh
Last active Jun 6, 2016
Creates a toolchain on linux from a build created with `./swift/utils/build-script -R --llbuild --swiftpm --foundation --xctest`
View make-toolchain.sh
#!/bin/sh
set -e
if [ -z "${CONFIGURATION}" ]; then
CONFIGURATION=debug
fi
PLATFORM='unknown'
unamestr=`uname`
View Incremental.yaml
client:
name: swift-build
tools: {}
targets:
test: []
default: [<SeaExec.module>, <SeaLib.Foo>, <SeaLib.Bar>, <SeaExec.exe>, <SeaLib.module>]
commands:
/Users/aciid/mycode/swiftpmProjects/SwiftCMixed/.build/debug/SeaExec.build:
tool: mkdir
outputs: [/Users/aciid/mycode/swiftpmProjects/SwiftCMixed/.build/debug/SeaExec.build]
@aciidb0mb3r
aciidb0mb3r / Lockfile.md
Created Mar 8, 2016
Lock file proposal
View Lockfile.md

Lock File for Swift Package Manager

Introduction

A Lockfile file locking the state of resolved dependencies generated by swiftpm.

Motivation

Lockfile file can be helpful in situations like :

View unpack.pkg
$ pkgutil --expand swift-DEVELOPMENT-SNAPSHOT-2016-03-01-a-osx.pkg swift-DEVELOPMENT-SNAPSHOT-2016-03-01-a-osx
$ cd swift-DEVELOPMENT-SNAPSHOT-2016-03-01-a-osx
$ cd swift-DEVELOPMENT-SNAPSHOT-2016-03-01-a-osx-package.pkg
$ mv Payload Payload.zip
$ open .
double click to extract
$ cd Payload\ 2/usr/bin
$ ./swiftc -v
Apple Swift version 3.0-dev (LLVM b361b0fc05, Clang 11493b0f62, Swift 24a0c3de75)
View ast.swift
import Foundation
public func getASTString() -> String {
// get the file path for the file "test.json" in the playground bundle
// let filePath = NSBundle.mainBundle().pathForResource("FirstTtest", ofType: "ast")
// get the contentData
let contentData = NSFileManager.defaultManager().contentsAtPath("a.txt")
You can’t perform that action at this time.