Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
Always Be Shipping

Martin H. Normark martinnormark

:shipit:
Always Be Shipping
View GitHub Profile
@martinnormark
martinnormark / GrabGithubIssues.js
Created Apr 23, 2015
Grab list of Github issues currently selected
View GrabGithubIssues.js
var issues = [];
$("input[type=checkbox].js-issues-list-check:checked").each(function() {
var $check = $(this),
$title = $check.parents("li.js-issue-row").find("a.issue-title-link");
issues.push($title.text().replace(/(\r\n|\n|\r)/gm,"").replace(/ /g, "") + " #" + $check.val())
})
window.prompt("Copy to clipboard: Ctrl+C, Enter", issues.join("\r\n"));
@martinnormark
martinnormark / LogoView.swift
Created Apr 18, 2015
Swift enum to return ready-to-use UIImageView with a logo from asset library.
View LogoView.swift
import UIKit
enum LogoView : UIViewConvertible {
case Default()
case Large()
case Symbol()
// MARK: UIViewConvertible
var View: UIView {
switch self {
@martinnormark
martinnormark / mbxstyle.swift
Created Mar 27, 2015
Programmatically change map style in MapboxGL native with swift.
View mbxstyle.swift
// Using SwiftyJSON
var path = NSBundle.mainBundle().pathForResource("satellite-v7-debug", ofType: "json")
var styles = NSData(contentsOfFile: path!)
var jsonStyles = JSON(data: styles!)
let polygonCoordinates = [
[
8.702266216278076,
56.04999222180692
@martinnormark
martinnormark / BackgroundImageView.swift
Last active Dec 23, 2017
Full screen background view for iOS that adds blur and vibrancy effects.
View BackgroundImageView.swift
class BackgroundImageView : UIView {
private let bgImage = UIImageView(forAutoLayout: ())
private var blurView:UIVisualEffectView!
private var vibrancyView:UIVisualEffectView!
private var didSetupConstraints = false
var containerView: UIView? = nil {
willSet(container) {
removeContainerViewFromSuperview()
@martinnormark
martinnormark / apn-feedback
Created Jan 22, 2015
Query the Apple Push Notification Feedback service using Houston (Nomad-CLI)
View apn-feedback
#!/usr/bin/env ruby
require 'houston'
certificate = 'cert.pem'
passphrase = ''
client = Houston::Client.production
client.certificate = File.read(@certificate)
client.passphrase = @passphrase
View ZuMoGetCurrentUser.cs
public static async Task<ZuMoLoginProviderCredentials> GetCurrentUser(this ApiController controller)
{
ServiceUser serviceUser = controller.User as ServiceUser;
if (serviceUser != null)
{
var identity = await serviceUser.GetIdentitiesAsync();
var credentials = identity.OfType<ZuMoLoginProviderCredentials>().FirstOrDefault();
return credentials;
@martinnormark
martinnormark / updateConstraints.swift
Last active Sep 2, 2015
Example of updateConstraints using PureLayout
View updateConstraints.swift
private var didUpdateConstraints: Bool = false
override func updateConstraints() {
if (!didUpdateConstraints) {
self.buildStatusIndicatorView.autoPinEdgesToSuperviewEdgesWithInsets(UIEdgeInsetsZero, excludingEdge: ALEdge.Trailing)
self.buildStatusIndicatorView.autoSetDimension(ALDimension.Width, toSize: 10)
self.buildNumberLabel.autoPinEdgesToSuperviewEdgesWithInsets(UIEdgeInsets(top: 5, left: 15, bottom: 5, right: 5), excludingEdge: ALEdge.Bottom)
self.buildNumberLabel.autoSetDimension(ALDimension.Height, toSize: 23)
@martinnormark
martinnormark / LoginViewController.swift
Created Dec 31, 2014
Correctly scaling a full size background image in iOS, to seamlessly transition from launch image
View LoginViewController.swift
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = UIColor.whiteColor()
let screenSize: CGRect = UIScreen.mainScreen().bounds
var bgImage = UIImageView(image: UIImage(named: "login-bg"))
bgImage.center = CGPointMake(self.view.bounds.size.width / 2, self.view.bounds.size.height / 2)
bgImage.transform = CGAffineTransformMakeScale(screenSize.width / 414, screenSize.height / 736)
View MixpanelUsageTracker.cs
public class MixpanelUsageTracker
{
#if DEBUG
/// <summary>
/// Test site
/// </summary>
public const string Token = "TOKEN";
#else
/// <summary>
/// Production site
@martinnormark
martinnormark / EmailUpload.cs
Created Jul 28, 2014
Class for storing e-mails posted by Mailgun callbacks.
View EmailUpload.cs
public class EmailUpload
{
[Required]
public string FromEmail { get; set; }
[Required]
public string RecipientEmail { get; set; }
[Required]
public string Subject { get; set; }
You can’t perform that action at this time.