Skip to content

Instantly share code, notes, and snippets.

View martinnormark's full-sized avatar
:shipit:
Always Be Shipping

Martin Høst Normark martinnormark

:shipit:
Always Be Shipping
View GitHub Profile
@martinnormark
martinnormark / updateConstraints.swift
Last active September 23, 2020 08:56
Example of updateConstraints using PureLayout
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 December 31, 2014 14:38
Correctly scaling a full size background image in iOS, to seamlessly transition from launch image
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)
@martinnormark
martinnormark / MixpanelUsageTracker.cs
Last active August 29, 2015 14:08
Mixpanel ASP.NET MVC
public class MixpanelUsageTracker
{
#if DEBUG
/// <summary>
/// Test site
/// </summary>
public const string Token = "TOKEN";
#else
/// <summary>
/// Production site
@martinnormark
martinnormark / EmailUpload.cs
Created July 28, 2014 20:27
Class for storing e-mails posted by Mailgun callbacks.
public class EmailUpload
{
[Required]
public string FromEmail { get; set; }
[Required]
public string RecipientEmail { get; set; }
[Required]
public string Subject { get; set; }
@martinnormark
martinnormark / other-bridges-above.xml
Created March 18, 2014 00:28
Overpass query to get all roads inside a bounding box, that is either a tunnel or has some kind of bridge above.
<osm-script output="json" timeout="25">
<!-- Bridges -->
<query type="way">
<has-kv k="bridge" regv="^(yes|viaduct)$"/>
<has-kv k="railway" modv="not" regv="." />
<bbox-query {{bbox}}/>
</query>
<!-- Find roads below the above bridges -->
@martinnormark
martinnormark / MailgunUploadController.cs
Last active October 5, 2017 22:17
Receive e-mails from Mailgun routes in ASP.NET MVC
using System;
using System.IO;
using System.Web;
using System.Web.Mvc;
namespace WebApp
{
public class MailgunUploadController : Controller
{
//
@martinnormark
martinnormark / rename_replace.ps1
Created February 4, 2014 18:46
Rename file names and replace within multiple files using Powershell
ls *.* -rec | %{ $f=$_; (gc $f.PSPath) | %{ $_ -replace "SEARCH", "REPLACEMENT" } | sc $f.PSPath }
Get-ChildItem *.* -rec | Rename-Item -NewName { $_.Name -replace 'SEARCH','REPLACEMENT' }
@martinnormark
martinnormark / predicate.cs
Created October 2, 2013 08:50
LLBLGen predicates
(CustomerFields.City.IsNotNull().And(CustomerFields.Country == "Denmark"))
@martinnormark
martinnormark / SearchSuggestionsAPI.cs
Created September 27, 2013 10:39
Simple C# API Client for the Google Search Suggestions API
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace ConsoleApplication1
{
public class SearchSuggestionsAPI
@martinnormark
martinnormark / google-search-suggestion-results.xml
Last active December 24, 2015 01:50
Using the Google Search Suggestions API from C#
<toplevel>
<CompleteSuggestion>
<suggestion data="mountain bikes"/>
</CompleteSuggestion>
<CompleteSuggestion>
<suggestion data="mountain bike parts"/>
</CompleteSuggestion>
<CompleteSuggestion>
<suggestion data="mountain bike sizing"/>
</CompleteSuggestion>