This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def integer? | |
ActivePattern::Pattern.build do |value, pass| | |
if value.is_a? Integer | |
value | |
elsif value.is_a? String | |
/\A[-+]?\d+\z/ === value ? value.to_i : pass | |
else | |
pass | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
popup-link value="Click Me" placement="bottom" | |
| Hey there. | |
a click="hide target='popover'" href="#" Close |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var // Static reference to slice | |
sliceDeferred = [].slice; | |
/* $.when that waits for everything to return before failing */ | |
function whenAll( firstParam ) { | |
var args = sliceDeferred.call( arguments, 0 ), | |
i = 0, | |
length = args.length, | |
pValues = new Array( length ), | |
count = length, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> _.split([1, 2, 3, 4], function(item) { return [item, item*2]; }) | |
[1, 2, 2, 4, 3, 6, 4, 8] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
_ajax: function(path, method, data, retry) { | |
var self = this; | |
var response = self._session.pipe(function(session) { | |
return $.ajax({ | |
type: method || "GET", | |
url: SalesForceSettings.proxyUrl, | |
cache: false, | |
processData: false, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Template Test</title> | |
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0.beta2/handlebars.min.js"></script> | |
<script type="text/javascript"> | |
$(function() { | |
$("script[type='text/x-handlebars-template']").each(function(i, el) { | |
var source = $(el).data("source"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Baton : IBaton { | |
private static Wiimote wiimote; | |
public Baton() { | |
if (wiimote == null) { | |
wiimote = new Wiimote(); | |
wiimote.Connect(); | |
wiimote.SetReportType(InputReport.IRAccel, true); | |
wiimote.SetLEDs(false, false, false, false); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static string EnumOptions<T>() | |
{ | |
if (!typeof(T).IsEnum) | |
return string.Empty; | |
return Enum.GetNames(typeof (T)) | |
.Select(s => string.Format("\'{0}\'", s)) | |
.Aggregate((lhs, rhs) => string.Format("{0}, {1}", lhs, rhs)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static readonly MediaTypeCollection mediaTypes = ((MediaTypesConfigSection)ConfigurationManager.GetSection("typeSection")).MediaTypes; | |
public static ActionResult With(this Controller controller, params Func<object, ActionResult>[] responses) | |
{ | |
string format = controller.ControllerContext.RouteData.Values["format"] as string ?? "html"; | |
var match = responses.First( | |
r => Lookup(r.Method.GetParameters()[0].Name, format)); | |
MediaType type = mediaTypes[match.Method.GetParameters()[0].Name]; | |
if (type != null) | |
controller.Response.ContentType = type.Name; |
NewerOlder