Skip to content

Instantly share code, notes, and snippets.

@iamphill
iamphill / RegexHandler.go
Last active May 9, 2022 02:12
Very basic golang HTTP server
package main
import (
"net/http"
"Regexp"
)
type route struct {
pattern *regexp.Regexp
handler http.Handler
@iamphill
iamphill / inner.js
Created January 22, 2014 11:43
IE8 doesn't have window.innerWidth or window.innerHeight So here is two functions to help with that.
/**
* Get window width
**/
var getWindowWidth = function() {
return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
};
/**
* Get window height
**/
@iamphill
iamphill / snippet.cs
Last active December 23, 2015 06:29
Create a snippet of text with the specified length
public static string CreateSnippet(string s, int length)
{
if (String.IsNullOrEmpty(s))
{
return "";
}
const string Ellipsis = "...";
if (s.Length > length)
{
@iamphill
iamphill / gist:5338003
Created April 8, 2013 16:06
Popup Present Model View
- (void)presentModalViewController:(UIViewController *)modalViewController fromView:(UIView *)view
{
if(SYSTEM_VERSION_LESS_THAN(@"6.0")) {
[modalViewController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentViewController:modalViewController animated:YES completion:nil];
} else {
modalViewController.modalPresentationStyle = UIModalPresentationFormSheet;
UIGraphicsBeginImageContext(self.view.window.frame.size);
[self.view.window.layer renderInContext:UIGraphicsGetCurrentContext()];
@iamphill
iamphill / gradients
Created January 9, 2013 08:30
CSS Gradients, includes IE. For future reference when I need the IE filter, who can actually remember that?!
background:#ffffff;
background: -webkit-linear-gradient(top, #ecebeb 0%, #ffffff 50%, #ecebeb 100%);
background: -moz-linear-gradient(top, #ecebeb 0%, #ffffff 50%, #ecebeb 100%);
background: -o-linear-gradient(top, #ecebeb 0%, #ffffff 50%, #ecebeb 100%);
background: linear-gradient(top, #ecebeb 0%, #ffffff 50%, #ecebeb 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#ecebeb');
@iamphill
iamphill / index.html
Last active October 20, 2015 15:32
Trello shadow DOM
<style>
trello-board {
display: block;
height: 100%;
}
</style>
<script src="http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars.min-latest.js"></script>
<script id="trello-board" type="text/x-handlebars-template">
<style>
trello-list {
@iamphill
iamphill / head.phtml
Last active September 28, 2015 11:56
Magento head
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<title><?php echo $this->getTitle(); ?></title>
<meta name="description" content="<?php echo htmlspecialchars( $this->getDescription() ); ?>">
<meta name="keywords" content="<?php echo $this->getKeywords(); ?>">
<?php $_currentProduct = Mage::registry('current_product'); ?>
@iamphill
iamphill / .gitconfig
Last active September 24, 2015 08:35
Git config file aliases
[push]
default = simple
[alias]
lg1 = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
lg = !"git lg1"
s = status
@iamphill
iamphill / test.css
Created July 21, 2015 06:59
SASS nested namespace properties
#test {
font-family: Helvetica, Arial, sans-serif;
font-size: 2em;
margin-left: 20px;
margin-top: 20px;
padding-right: 50px;
padding-left: 50px; }
@iamphill
iamphill / style.scss
Created May 26, 2015 14:37
SCSS spacing utility
$prefix: space;
// All available sizs
$sizes: (
"n": 0,
"xs": 5px,
"s": 10px,
"m": 15px,
"l": 20px,
"xl": 25px