Skip to content

Instantly share code, notes, and snippets.

@SteveRohrlack
SteveRohrlack / inline-asm-multiline.c
Created November 4, 2019 13:51
c/c++ inline asm multiline
asm volatile(R"(
# r1 = 0
mov r1, #0
# r1 += 5
add r1, r1, #5
# r1 -= 1
sub r1, r1, #1
)");
@SteveRohrlack
SteveRohrlack / apple-framework-enum-vs-custom-enum.swift
Last active October 5, 2016 06:54
Apple framework enum vs custom enum
import UIKit
// Mark: custom enum
enum Toast: Int {
case raw = 1
case black
}
if let toast = Toast.init(rawValue: 999) {
@SteveRohrlack
SteveRohrlack / DynamicSshExecutablePath.rake
Created September 20, 2016 12:26
capistrano-dynamic-ssh-executable-path
# tested for capistrano 3.6.1
Rake::Task["deploy:check"].clear_actions
namespace :deploy do
task check: :'git:wrapper' do
on release_roles :all do
execute :mkdir, "-p", "#{fetch(:tmp_dir)}/#{fetch(:application)}/"
upload! StringIO.new("#!/bin/sh -e\nexec /usr/bin/env ssh -o PasswordAuthentication=no -o StrictHostKeyChecking=no \"$@\"\n"),fetch(:git_wrapper_path)
execute :chmod, "+x", fetch(:git_wrapper_path)
@SteveRohrlack
SteveRohrlack / generic-equatable-protocol.swift
Created September 13, 2016 07:58
Swift 2.2 example showing how a generic protocol can be "Equatable"
import Foundation
/**
generic protocol that is Equatable by itself
and wraps any equatable data type
*/
protocol SameOldThingable: Equatable {
associatedtype DataType: Equatable
var data: DataType { get set }
@SteveRohrlack
SteveRohrlack / swift-property-visibility.swift
Last active June 13, 2016 10:12
swift property visibility
public struct Book {
public private(set) var page: Int
public mutating func browseTo(page requestedPage: Int) {
page = requestedPage
/// show requested page
/// do other things that have to be done when
/// changing the current page
@SteveRohrlack
SteveRohrlack / swift-enumerations-with-named-associated-values.swift
Created June 1, 2016 07:15
swift enumerations with named associated values
enum MonitorType {
case widescreen(size: Int, refreshRate: Int, manufacturer: String)
case ultrawidescreen(size: Int, refreshRate: Int, manufacturer: String)
}
let widescreenMonitor: MonitorType = .widescreen(size: 26, refreshRate: 6, manufacturer: "Apple")
let ultraWidescreenMonitor: MonitorType = .ultrawidescreen(size: 28, refreshRate: 6, manufacturer: "Eizo")
@SteveRohrlack
SteveRohrlack / xcode-profile.sh
Created May 20, 2016 10:06
profile swift compilation times
xcodebuild -workspace MyApp.xcworkspace -scheme MyApp clean build \
OTHER_SWIFT_FLAGS="-Xfrontend -debug-time-function-bodies" > compiletimes.debug
@SteveRohrlack
SteveRohrlack / swift.gitignore
Last active January 17, 2023 05:51
swift .gitignore template
# see https://gist.github.com/muhasturk/df28ec9d2cc18bf1cfc8
# see https://github.com/github/gitignore/blob/master/Swift.gitignore
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata
#
# *.lock - this is used and abused by many editors for many different things.
# For the main ones I use (e.g. Eclipse), it should be excluded
@SteveRohrlack
SteveRohrlack / .gitignore
Created April 28, 2016 11:36
.gitignore Template
# Project specific
# ...
# Project Dev
logs/*
build/*
!build/.gitkeep
!logs/.gitkeep
/vendor/
@SteveRohrlack
SteveRohrlack / Dockerfile-example-sitespeedio
Created April 22, 2016 07:08
Dockerfile example: running sitespeed.io using grunt
FROM java:7
MAINTAINER Steve Rohrlack
# docker run -v $HOME/example-project/sitespeedio-logs/:/usr/local/src/example-project/sitespeedio-logs/ default
# sitespeed.io will write log files and reports to a defined directory
# configure environment
ENV DEBIAN_FRONTEND noninteractive