Skip to content

Instantly share code, notes, and snippets.

View samandmoore's full-sized avatar

Sam Moore samandmoore

View GitHub Profile
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
require 'html2textile'
first_block = <<END
<div class="column span-3">
<h3 class="storytitle entry-title" id="post-312">
<a href="http://jystewart.net/process/2007/11/converting-html-to-textile-with-ruby/" rel="bookmark">Converting HTML to Textile with Ruby</a>
</h3>
<p>
<span>23 November 2007</span>
@{
Func<ModelMetadata, bool> ShouldShow = metadata =>
metadata.ShowForEdit && !ViewData.TemplateInfo.Visited(metadata);
}
@if (ViewData.TemplateInfo.TemplateDepth > 5) {
if (Model == null) {
@ViewData.ModelMetadata.NullDisplayText
} else {
@ViewData.ModelMetadata.SimpleDisplayText
}
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@warrenbuckley
warrenbuckley / TwitterFeed.cshtml
Created January 31, 2012 13:36
Umbraco V5 Example - Twitter Feed
@inherits PartialViewMacroPage
@using Umbraco.Cms.Web
@using Umbraco.Cms.Web.Macros
@using Umbraco.Framework
@{
@* Macro Param: Twitter Username that defaults to umbraco if empty *@
var twitterUsername = String.IsNullOrEmpty(Model.MacroParameters.twitterUsername) ? "umbracoproject" : Model.MacroParameters.twitterUsername;
@meleyal
meleyal / macvim-padding
Created February 24, 2012 18:42
Add padding to MacVim windows
defaults write org.vim.MacVim MMTextInsetTop '10'
defaults write org.vim.MacVim MMTextInsetLeft '10'
defaults write org.vim.MacVim MMTextInsetBottom '10'
defaults write org.vim.MacVim MMTextInsetRight '10'
@calo81
calo81 / LoggerFilter
Created March 18, 2012 12:48
Filter for reading and logging HttpServletRequest body, and resetting the input stream
package com.paddypower.financials.market.management.rest.logging;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
@clipperhouse
clipperhouse / gist:2321739
Created April 6, 2012 18:11
Cross-platform mobile orientation change detection
if (window.onorientationchange) {
window.onorientationchange = updateOrientation;
} else {
window.onresize = updateOrientation;
}
var body = $(document.body);
function updateOrientation() {
var islandscape = window.orientation != null ? window.orientation != 0 : window.innerWidth > window.innerHeight;
body.toggleClass("landscape", islandscape);
}
@drch-
drch- / project.msbuild
Created April 29, 2012 15:26
Running AjaxMin on sets of files at build time
<Target Name="AfterBuild">
<CallTarget Targets="MinifyJs" />
</Target>
<PropertyGroup>
<AjaxMin>"C:\Program Files (x86)\Microsoft\Microsoft Ajax Minifier\AjaxMin.exe"</AjaxMin>
</PropertyGroup>
<Target Name="MinifyJs">
<ItemGroup>
@bradwilson
bradwilson / My.Types.ps1xml
Created May 2, 2012 03:54
My profile.ps1 (and several related scripts)
<Types>
<Type>
<Name>System.String</Name>
<Members>
<ScriptProperty>
<Name>ToBase64</Name>
<GetScriptBlock>
[System.Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($this))
</GetScriptBlock>
</ScriptProperty>