Skip to content

Instantly share code, notes, and snippets.

@petebarber
petebarber / ViewController.swift
Created Jan 3, 2018
View Controller from the Resizable project
View ViewController.swift
import UIKit
class ViewController: UIViewController, UIPickerViewDataSource, UIPickerViewDelegate
{
@IBOutlet weak var picker: UIPickerView!
@IBOutlet weak var redRectView: UIView!
var viewToUse: UIView?
var window: UIView?
var pinch: UIPinchGestureRecognizer?
var rotate: UIRotationGestureRecognizer?
View UnitTestingLocalDynamoDB.js
'use strict';
const assert = require("assert");
const sinon = require("sinon");
const aws = require("aws-sdk");
const spawn = require("child_process").spawn;
aws.config.update({region: "us-east-1" });
describe("AWSLambdaToTest", function()
{
View TestLambda.js
'use strict';
const AWS = require("aws-sdk");
const errors = require("./Errors.js");
const findUserByEmailAddress = function(emailAddress)
{
AWS.config.dynamodb = { endpoint: "http://localhost:8000" };
const docClient = new AWS.DynamoDB.DocumentClient();
View LocalDynamoDBStartStop.js
'use strict';
const assert = require("assert");
const sinon = require("sinon");
const aws = require("aws-sdk");
const spawn = require("child_process").spawn;
aws.config.update({region: "us-east-1" });
describe("awsLambdaToTest", function()
{
View deferTest.swift
enum WhenToReturn
{
case After0
case After1
case After2
}
func deferTest(whenToReturn: WhenToReturn, shouldBranch: Bool)
{
print("Defer Test - whenToReturn:\(whenToReturn), shouldBranch:\(shouldBranch)")
View TypeErasure.cpp
#include <iostream>
#include <vector>
#include <string>
class ISimpleBoundFunctorBase
{
public:
ISimpleBoundFunctorBase(const std::string& id)
: _id(id)
{
@petebarber
petebarber / grass.swift
Last active Aug 29, 2015
OSX/Cocoa command line program to create a bitmap, draw into it and save as a PNG. In this case it draws triangles that are used a basic grass asset
View grass.swift
import Cocoa
private func saveAsPNGWithName(fileName: String, bitMap: NSBitmapImageRep) -> Bool
{
let props: [NSObject:AnyObject] = [:]
let imageData = bitMap.representationUsingType(NSBitmapImageFileType.NSPNGFileType, properties: props)
return imageData!.writeToFile(fileName, atomically: false)
}
@petebarber
petebarber / private.xml
Last active Jan 2, 2016
Custom key mappings for KeyRemap4MacBook to enable PC development on OS X
View private.xml
<?xml version="1.0"?>
<root>
<appdef>
<appname>INTELLIJ</appname>
<equal>com.jetbrains.intellij</equal>
</appdef>
<replacementdef>
<replacementname>MY_IGNORE_APPS</replacementname>
<replacementvalue>VIRTUALMACHINE, TERMINAL, REMOTEDESKTOPCONNECTION, VNC, INTELLIJ</replacementvalue>
@petebarber
petebarber / gist:6236315
Created Aug 14, 2013
Capturing lvalue references in C++11 lambdas sample code
View gist:6236315
#include <iostream>
#include <typeinfo>
void ref2ref()
{
std::cout << "ref2ref\n";
int foo = 7;
int& rfoo = foo;
int& rfoo1 = rfoo;