Skip to content

Instantly share code, notes, and snippets.

View chrisschreiner's full-sized avatar

Chris Schreiner chrisschreiner

  • Schpaencoder
  • Oslo, Norway, Europe
View GitHub Profile
//Swift 2.0
import Foundation
protocol vcProtocol {
func hidePuzzleMessage()
func showPuzzleMessage()
func prepareBoard()
}
class ViewController: vcProtocol {
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
import UIKit
import XCPlayground
import Framework2
enum PlayerPerspective {
case Black, White
}
class SampleChessBoardView : UIView {
var margin: CGFloat = 15
import XCPlayground
import UIKit
import Framework3
XCPSetExecutionShouldContinueIndefinitely()
var r = request(.GET, "http://en.lichess.org/api/user/peropaal")
.response { (request, response, data, error) in
println(request)
println()
import Cocoa
struct Constraint {
typealias T = (attribute: CAConstraintAttribute, relativeTo:String, relatedAttribute: CAConstraintAttribute, offset: CGFloat)
let data: T
func create() -> CAConstraint {
let newConstraint: AnyObject! = CAConstraint.constraintWithAttribute(data.attribute, relativeTo: data.relativeTo, attribute: data.relatedAttribute, offset: data.offset)
return newConstraint as CAConstraint
}
@chrisschreiner
chrisschreiner / gist:db32cde87300c0e76017
Created September 5, 2014 08:40
Writing succinct constraints
import Cocoa
struct Constraint {
typealias T = (attribute: CAConstraintAttribute, relativeTo:String, relatedAttribute: CAConstraintAttribute, offset: CGFloat)
let data: T
func create() -> CAConstraint {
let newConstraint: AnyObject! = CAConstraint.constraintWithAttribute(data.attribute, relativeTo: data.relativeTo, attribute: data.relatedAttribute, offset: data.offset)
return newConstraint as CAConstraint
}
///
- (ConfigureCellBlock)dimmedCell {
return [[^(UITableViewCell *cell) {
cell.backgroundColor = [self colorFor:@"sub.cell.background"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
} copy] autorelease];
}
///
- (ConfigureBadgeBlock)standardBadge {
// log every category
[[L4Logger rootLogger] setLevel:[L4Level all]];
// send log messages to console
L4ConsoleAppender *consoleAppender=[[[L4ConsoleAppender alloc] initTarget:YES withLayout: [L4Layout simpleLayout]] autorelease];
[[L4Logger rootLogger] addAppender: consoleAppender];
L4Logger *theLogger = [L4Logger loggerForClass:[L4FunctionLogger class]];
[theLogger setLevel:[L4Level debug]];
//
log4Info(@"The logging system has been initialized.");
@chrisschreiner
chrisschreiner / color-utils.clj
Created July 11, 2010 12:00
Color utilities for CSS
(import 'java.awt.Color)
(def *default-color-fraction* 0.2)
(def *default-blend-fraction* 0.5)
(defn- format-hex [c]
(str "#" (format "%02x%02x%02x"
(.getRed c)
(.getGreen c)
(defn inside-byte [v]
(cond
(< v 0) 0
(> v 255) 255
:else v))
(defn darker- [color fraction]
(let [fr (- 1.0 fraction)
red (inside-byte (-> (.getRed color) (* fr) Math/round))
green (inside-byte (-> (.getGreen color) (* fr) Math/round))