Skip to content

Instantly share code, notes, and snippets.

@iamphill
iamphill / RegexHandler.go
Last active May 8, 2020
Very basic golang HTTP server
View RegexHandler.go
package main
import (
"net/http"
"Regexp"
)
type route struct {
pattern *regexp.Regexp
handler http.Handler
@iamphill
iamphill / inner.js
Created Jan 22, 2014
IE8 doesn't have window.innerWidth or window.innerHeight So here is two functions to help with that.
View inner.js
/**
* Get window width
**/
var getWindowWidth = function() {
return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
};
/**
* Get window height
**/
@iamphill
iamphill / snippet.cs
Last active Dec 23, 2015
Create a snippet of text with the specified length
View snippet.cs
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 Apr 8, 2013
Popup Present Model View
View gist:5338003
- (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 Jan 9, 2013
CSS Gradients, includes IE. For future reference when I need the IE filter, who can actually remember that?!
View gradients
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 Oct 20, 2015
Trello shadow DOM
View index.html
<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 Sep 28, 2015
Magento head
View head.phtml
<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 Sep 24, 2015
Git config file aliases
View .gitconfig
[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 Jul 21, 2015
SASS nested namespace properties
View test.css
#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
SCSS spacing utility
View style.scss
$prefix: space;
// All available sizs
$sizes: (
"n": 0,
"xs": 5px,
"s": 10px,
"m": 15px,
"l": 20px,
"xl": 25px
You can’t perform that action at this time.