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
var NUM_PARTICLES = ( ( ROWS = 100 ) * ( COLS = 300 ) ),
THICKNESS = Math.pow( 80, 2 ),
SPACING = 8,
MARGIN = 100,
DRAG = 0.95,
EASE = 0.25,
PARTICLE_SIZE = 5, // Size of each particle
PARTICLE_COLOR = {r: 0, g: 255, b: 0, a: 1}, // Color of each particle
DRAG = 0.95,
@martinnormark
martinnormark / BusinessLogicInstaller.cs
Created July 17, 2012 09:17
Castle Windsor IoC Container setup for ASP.NET MVC
using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;
using MyApp.BusinessLogic.Facades;
namespace MyApp.Web.PresentationLogic.Container
{
public class BusinessLogicInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
@martinnormark
martinnormark / DynamicHelper.cs
Created May 2, 2012 08:11
C# Dynamic extension methods for serializing to XML
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Xml;
using System.Xml.Linq;
/// <summary>
/// Extension methods for the dynamic object.
/// </summary>
@martinnormark
martinnormark / BackgroundImageView.swift
Last active August 2, 2022 09:42
Full screen background view for iOS that adds blur and vibrancy effects.
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()
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Tilt</title>
</head>
<body style="padding: 50px">
<div class="js-tilt" style="width: 300px; height: 300px; background-color: burlywood; display: flex; justify-content: center; align-items: center; overflow: hidden">
<img
src="https://images.unsplash.com/photo-1632993952737-0c2897164db3?ixid=MnwxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHwyfHx8ZW58MHx8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60"
@martinnormark
martinnormark / d3-mouse-over-line.js
Created March 22, 2016 11:53
Adding a vertical line to a D3 chart, that follows the mouse pointer.
var vertical = d3.select(".chart")
.append("div")
.attr("class", "remove")
.style("position", "absolute")
.style("z-index", "19")
.style("width", "1px")
.style("height", "380px")
.style("top", "10px")
.style("bottom", "30px")
.style("left", "0px")
@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)
using System;
using System.Windows;
using System.Windows.Threading;
namespace WpfApp1
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
@martinnormark
martinnormark / pr-cli-merge.ps1
Created May 7, 2021 06:27
Quickly merge multiple Pull Requests from PowerShell.
$prs = gh pr list | Select-String -Pattern "\d\d\d" | Select-object -last 10
([regex]"\d\d\d").matches($prs) | % { gh pr merge $_.value -m -d }
@martinnormark
martinnormark / UrlHelperExtensions.cs
Last active December 21, 2020 11:18
Adding build number to static file paths for cache busting in ASP.NET MVC
public static class UrlHelperExtensions
{
private static int _revisionNumber;
public static string ContentVersioned(this UrlHelper urlHelper, string contentPath)
{
string url = urlHelper.Content(contentPath);
int revisionNumber = GetRevisionNumber();
return String.Format("{0}?v={1}", url, revisionNumber);