Skip to content

Instantly share code, notes, and snippets.

@MainasuK
MainasuK / NSViewControllerPreview.swift
Last active May 21, 2022 20:09 — forked from mattt/UIViewControllerPreview.swift
Generic structures to host previews of UIView and UIViewController subclasses. Also NSView and NSViewController
import Cocoa
#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct NSViewControllerPreview<ViewController: NSViewController>: NSViewControllerRepresentable {
let viewController: ViewController
init(_ builder: @escaping () -> ViewController) {
viewController = builder()
@mattt
mattt / UIViewControllerPreview.swift
Last active October 7, 2024 06:51
Generic structures to host previews of UIView and UIViewController subclasses.
import UIKit
#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct UIViewControllerPreview<ViewController: UIViewController>: UIViewControllerRepresentable {
let viewController: ViewController
init(_ builder: @escaping () -> ViewController) {
viewController = builder()
}
@SteveBenner
SteveBenner / macfix1-install-nokogiri.rb
Last active August 13, 2019 14:52
Mac fix - Install Nokogiri gem on OS X 10.9 Mavericks
#!/usr/bin/env ruby
#
# Mac fix 1 - Install the Nokogiri gem on Mac OS 10.9 Mavericks
#
# Usage: to configure and install using Bundler, pass in 'bundle' as an argument to the script.
#
# Nokogiri works at a very low level, so it has many issues on various platforms.
# As a result, the command `install gem nokogiri` often will fail. This fix is for
# errors involving 'libiconv', such as the following one I encountered:
#
# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end
# MODEL
class Case < ActiveRecord::Base
include Eventable
has_many :tasks
concerning :Assignment do
def assign_to(new_owner:, details:)
transaction do
@staxmanade
staxmanade / Podcasts.opml
Last active January 2, 2016 21:48
OPML of the current podcasts I'm listening to. These are not in any particular order. I'm using the [Downcast](https://geo.itunes.apple.com/us/app/downcast/id393858566?mt=8&at=10lPYJ) iPhone app and set it to 2x speed for twice the listening throughput! (Unless an interviewee has a strong accent).
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>Downcast Podcasts</title>
</head>
@dennisreimann
dennisreimann / changelog
Created November 20, 2013 21:10
CHANGELOG generator
#!/usr/bin/env ruby
#
# CHANGELOG generator
#
# Usage:
#
# $ changelog [SINCE UNTIL]
#
# This script collects git commits from a given range (SINCE and UNTIL
# are optional refs, SINCE defaults to the last tag, UNTIL to HEAD).
@mattt
mattt / UIImageForSwatchOfColorWithSize.h
Created September 27, 2013 01:25
Create a UIImage swatch of a color with a specified size.
static UIImage * UIImageForSwatchOfColorWithSize(UIColor *color, CGSize size) {
UIImage *image = nil;
CGRect rect = CGRectMake(0.0f, 0.0f, size.width, size.height);
UIGraphicsBeginImageContext(rect.size);
{
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(c, [color CGColor]);
@xpepper
xpepper / download_rubytapas.rb
Last active January 1, 2019 01:37
This script will download all the published rubytapas. Each episode, with all the attachments, will be downloaded in a folder named after the episode number. For example, in the folder "64" will be downloaded: 064-yield-or-enumerate.html, 064-yield-or-enumerate.mp4, 064-yield-or-enumerate.rb You need to set your credentials (username and passwor…
# username = "my_username"
# pwd = "my_password"
# target_path = "my_target_path"
# saving auth cookie
system %Q{wget --save-cookies /tmp/cookie.txt --keep-session-cookies --post-data "username=#{username}&password=#{pwd}" -O - \
https://rubytapas.dpdcart.com/subscriber/login?__dpd_cart=d08391e6-5fe2-4400-8b27-2dc17b413027}
(25..600).each do |i|
@mps
mps / Rakefile
Last active December 18, 2015 15:49
A rake task for revving plist build version numbers...
def revBuild(plistFile)
puts "Attempting to update #{plistFile} build version..."
oldVersion = `/usr/libexec/PlistBuddy -c "Print CFBundleVersion" #{plistFile}`
puts "The old version: #{oldVersion}"
versionParts = oldVersion.split(".")
previousDate = versionParts[2]
newDate = Time.now.strftime("%Y%m%d")
versionParts[2] = newDate