Skip to content

Instantly share code, notes, and snippets.

View ppeelen's full-sized avatar
🎯
Focusing, always!

Paul Peelen ppeelen

🎯
Focusing, always!
View GitHub Profile
@ppeelen
ppeelen / dabblet.css
Created December 17, 2011 23:09
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, brown);
min-height:100%;
extension NSDate {
func isGreaterThanDate(dateToCompare : NSDate) -> Bool {
return self.compare(dateToCompare) == NSComparisonResult.OrderedDescending
}
func isLessThanDate(dateToCompare : NSDate) -> Bool {
return self.compare(dateToCompare) == NSComparisonResult.OrderedAscending
}
@ppeelen
ppeelen / how-to-install-php-development-environment-on-osx.md
Last active August 6, 2017 22:13 — forked from jakebellacera/how-to-install-php-development-environment-on-osx.md
How to install a basic Apache, PHP and MySQL development environment with Homebrew. Mirrored from the Echo & Co. blog.

How to install a basic Apache, PHP and MySQL development environment with Homebrew

This guide will walk you through the steps required to install a basic Apache, PHP and MySQL development environment using homebrew. Basically, all you'll need to do is copy the commands below into Terminal. Copy one block at a time.

NOTE: this guide is mirrored from Echo & Co.'s blog in case the original blog post or the website decides to go down. I've shared this guide around many times to colleagues and friends. Please give Alan Ivey (@alanthing) all of the credit for publishing this really helpful guide.

Before we begin...

We're going to need to install homebrew, a super awesome package manager for OS X. Installation instructions are available on the homebrew website.

@ppeelen
ppeelen / .bash_profile
Last active August 27, 2018 12:31
My bash profile
# Update the path with other important bin folders
export PATH=$(echo $PATH | sed 's|/usr/local/bin||; s|/usr/local/sbin||; s|::|:|; s|^:||; s|\(.*\)|/usr/local/bin:/usr/local/sbin:\1|')
PATH="$PATH:~/bin:$HOME/.rvm/bin"
# Adding Bash Completion
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
# Show a different color on master & develop branch
{
"6.0.0": "https://dl.google.com/dl/cpdc/07041f585a34f209/GoogleTagManager-6.0.0.tar.gz"
}
@ppeelen
ppeelen / LazyFilter.swift
Last active June 9, 2021 14:35
Swift: Lazy filter with prefix. Check if occurrence of X happens more than Y times using filter
struct FooBar {
let state: Bool
func isTrue() -> Bool { state } // Called 1000 times
func isFalse() -> Bool { !state } // Called 92 times
}
let fooList = (0..<1000).compactMap { n in FooBar(state: Bool.random()) }
let start = CFAbsoluteTimeGetCurrent()
if fooList.filter({ $0.isTrue() }).count > 1 {
@ppeelen
ppeelen / RawRepresentableVsVar.swift
Last active June 14, 2021 10:14
An example on why not to try to reinvent the wheel, use the power of Swift.
import Foundation
enum FooBar: String, CaseIterable {
case Foo
case Bar
}
enum BarFoo: CaseIterable {
case Bar
case Foo
@ppeelen
ppeelen / ArrayPartition.swift
Created August 19, 2021 19:52
This extension will partition an array into an array with sub items depending on the parent item. It is mean to de-flatten a flattened array.
import Foundation
// The definition of our struct
struct FooBar: Equatable{
enum ItemType {
case main, sub
}
let itemType: ItemType
let name: String
@ppeelen
ppeelen / DictionaryComparison.swift
Created October 12, 2021 05:59
Dictionary comparison
import Foundation
let dictOne: [String: String] = [
"key1": "value one",
"key2": "value two",
"key3": "value three",
"key4": "value four"
]
let dictTwo: [String: String] = [
@ppeelen
ppeelen / codecov.sh
Last active May 31, 2022 12:13
Generating CodeCov JSON report from CLI
# Run tests with enableCodeCov YES, e.g. fastlane scan with code_coverage: true
# In your derived_data folder, run the following:
xcrun xcresulttool merge Logs/Test/*.xcresult --output-path bundle.xcresult # Combines all the XCResult files
xcrun xccov view --report --json bundle.xcresult > CodeCov-report.json # Generates the report into a JSON file