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 / rename_replace.ps1
Created Feb 4, 2014
Rename file names and replace within multiple files using Powershell
View rename_replace.ps1
ls *.* -rec | %{ $f=$_; (gc $f.PSPath) | %{ $_ -replace "SEARCH", "REPLACEMENT" } | sc $f.PSPath }
Get-ChildItem *.* -rec | Rename-Item -NewName { $_.Name -replace 'SEARCH','REPLACEMENT' }
@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; }
View MixpanelUsageTracker.cs
public class MixpanelUsageTracker
{
#if DEBUG
/// <summary>
/// Test site
/// </summary>
public const string Token = "TOKEN";
#else
/// <summary>
/// Production site
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 / 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 / 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 / create_labels.sh
Last active Aug 29, 2015 — forked from omegahm/create_labels.sh
Create Gtihub labels from Bash
View create_labels.sh
#!/usr/bin/env bash
# Colours picked from https://robinpowered.com/blog/best-practice-system-for-organizing-and-tagging-github-issues/
###
# Label definitions
###
declare -A LABELS
# Platform
@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 / MvcActionFilterTestHelper.cs
Created May 5, 2012
Method for verifying that a method contains an Attribute
View MvcActionFilterTestHelper.cs
/// <summary>
/// Verifies the controller action, contains an attribute of the specified attributeType.
/// </summary>
/// <param name="controller">The controller.</param>
/// <param name="action">The action method.</param>
/// <param name="attributeType">Type of the attribute to look for.</param>
/// <returns>Returns true if the attribute was present on the action. Otherwise false.</returns>
public static bool VerifyControllerActionAttribute(this Controller controller, Func<ActionResult> action, Type attributeType)
{
MethodInfo methodInfo = action.Method;
You can’t perform that action at this time.