Skip to content

Instantly share code, notes, and snippets.

@carlossless
carlossless / generate-changelog.sh
Created Nov 24, 2015
A script to parse a given range of the current git repo log, find Jira issue Ids and print out links to them
View generate-changelog.sh
#!/bin/bash
COMMIT_RANGE=$TRAVIS_COMMIT_RANGE
JIRA_ISSUE_PREFIX="VI-"
JIRA_ISSUE_BASE_URL="https://mycompany.atlassian.net/browse/"
if [ -z "$COMMIT_RANGE" ]; then >&2 echo "Commit Range is Empty. Exiting."; exit 0; fi
GIT_LOG=`git log --pretty=format:'%h %ad %s | %an' --date=short "$COMMIT_RANGE" | grep -v Merge | sed -E 's/.{7} (.*)/\1/g'`
@carlossless
carlossless / ModuleA.swift
Last active Nov 19, 2015
Linker Failure when assigning a protocol with a getter for a struct property in a different framework
View ModuleA.swift
import Foundation
import ModuleB
public protocol CacheableConfiguration: Decodable {
static var fileName: String { get }
var version: Int { get } // this is what is triggering the linker fail
func object() -> AnyObject
}
@carlossless
carlossless / regenerate-models-xcode.sh
Created Apr 11, 2015
Data and Resource Model Regeneration Xcode scripts
View regenerate-models-xcode.sh
PATH=/usr/local/bin/:${PATH}
if command -v mogenerator >/dev/null 2>&1; then
mogenerator --v2 --model "$SRCROOT"/TeamApp/Database/TeamApp.xcdatamodeld --human-dir "$SRCROOT"/TeamApp/Database/Models --machine-dir "$SRCROOT"/TeamApp/Database/Models/Generated
else
echo "warning: You have to install and set up mogenerator to generate the data models"
fi
PATH=/usr/local/bin/:${PATH}
if command -v xcres >/dev/null 2>&1; then
xcres --no-ansi build "$PROJECT_FILE_PATH" "$SRCROOT"/TeamApp/Resources/R
@carlossless
carlossless / monty-hall.c
Last active Mar 29, 2017
A statistical simulation of the Monty Hall problem.
View monty-hall.c
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int rand_lim(int limit);
int try_game();
int main ()
{
srand(time(NULL));
@carlossless
carlossless / jenkins-port-forwarding.md
Last active Dec 15, 2020
Port Forwarding (8080 -> 80) with `pf` on Mavericks/Yosemite
View jenkins-port-forwarding.md

Jenkins Port Forwarding (8080 -> 80) with pf on Mavericks/Yosemite

This guide is a fork from this gist. I've added minor adjustments to customise these rules to forward connections from an outsite interface like en0.

Since Mavericks stopped using the deprecated ipfw (as of Mountain Lion), we'll be using pf to allow port forwarding.

1. Create the anchor file

Create an anchor file under /etc/pf.anchors/com.jenkins with your redirection rule like:

@carlossless
carlossless / rotating-image-frames-from-imageview.m
Last active Aug 29, 2015
Create PNG Animation Frame Images by Animating an UIImageView
View rotating-image-frames-from-imageview.m
- (void)makeRotatedImagesWithImageView:(UIImageView *)imageView
{
for (int i = 0; i < 30; i++) {
CGFloat angle = M_PI / 15 * i;
CGSize boundingSize = imageView.image.size;
boundingSize.width *= 2;
boundingSize.height *= 2;