Skip to content

Instantly share code, notes, and snippets.

@mps
mps / ContentView.swift
Created December 17, 2021 19:02
A little stopwatch
class Stopwatch: ObservableObject {
@Published private var progressTime = 58
var hours: String {
let time = progressTime / 3600
return time < 10 ? "0\(time)" : "\(time)"
}
var minutes: String {
let time = (progressTime % 3600) / 60
@mps
mps / lul.m
Created September 4, 2019 18:48
Code I found today
- (void) handleRequest
{
// Wait up to five seconds for the network to be worth trying.
for (int i = 0; i < 5; i++)
{
if (NetworkWorthTrying()) return;
[NSThread sleepForTimeInterval:1.0];
}
}
@mps
mps / Rakefile
Last active August 29, 2015 14:14
Automate Everything
# Rakefiles are a great way to automate your life
#
# Below are some example tasks I use each day in my
# iOS development.
#
# Do not get caught up in the missing implementation, but
# just take in the simplicity of each task as a time saving element.
#
# Let me know what you think via @strickland on Twitter.
<!DOCTYPE html>
<script>var __pbpa = true;</script><script>var translated_warning_string = 'Warning: Never enter your Tumblr password unless \u201chttps://www.tumblr.com/login\u201d\x0ais the address in your web browser.\x0a\x0aYou should also see a green \u201cTumblr, Inc.\u201d identification in the address bar.\x0a\x0aSpammers and other bad guys use fake forms to steal passwords.\x0a\x0aTumblr will never ask you to log in from a user\u2019s blog.\x0a\x0aAre you absolutely sure you want to continue?';</script><script type="text/javascript" language="javascript" src="http://assets.tumblr.com/assets/scripts/pre_tumblelog.js?_v=0fe6931f685c5a29060675a836044a62"></script>
<!doctype html>
<html>
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# blog: http://ogp.me/ns/blog#">
<meta charset="utf-8">
<!-- Always force latest IE rendering engine or request Chrome Frame -->
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<!-- Use title if it's in the page YAML frontmat
@mps
mps / wordpress-xml-jekyll-importer.rb
Created July 31, 2014 13:23
Modify Jekyll Importer to load xml file and then treat posts as markdown
# coding: utf-8
# This importer takes a wordpress.xml file, which can be exported from your
# wordpress.com blog (/wp-admin/export.php).
require 'jekyll-import'
module JekyllImport
module Importers
class CustomWordpress < Importer
def self.require_deps
@mps
mps / Rakefile
Created September 24, 2013 14:16
Some rakefile fun for uploading a config json file, supports branching / pr
require 'aws-sdk'
require 'hub'
######################
#### CONFIG STUFF ####
######################
desc 'Update Config Files'
task :config do
puts 'Updating config files...'
source 'http://rubygems.org'
# Make sure you have bundler installed
# gem install bundler
gem 'shenzhen'
@mps
mps / Localizable.strings
Created June 26, 2013 17:05
French Gitty Translation
/* Localized versions of Info.plist keys French */
"Credits" = "Crédits";
"Here are some great libraries I used to create this application:" = "Here are some great libraries I used to create this application:";
"About" = "À propos";
"Thank You" = "Remerciements";
"Thank you to the amazing team at GitHub for creating a great product, without their hard work, none of this would have been possible." = "Merci à l'équipe extraordinaire à GitHub pour créer un excellent produit, sans leur travail acharné, rien de tout cela n'aurait été possible.";
"About the Developer" = "À propos du Développeur";
"Icon Design" = "Icon Design";
@mps
mps / xml_image_downloader.rb
Created June 20, 2013 22:02
Open an XML file and download images from its nodes...
require 'rubygems'
require 'nokogiri'
require 'open-uri'
XML_FILE_LOCATION = 'path/to/my/xml/file.xml'
XML_XPATH = '//ANode'
XML_ATTR_FOR_IMAGE_NAME = 'imagename'
XML_ATTR_FOR_IMAGE_URL = 'imageurl'
file = File.open(XML_FILE_LOCATION, "rb")
@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