Skip to content

Instantly share code, notes, and snippets.

@joecritch
joecritch / react.if.js
Last active August 29, 2015 13:55
Conditional function, compatible with React's JSX precompiler
React.if = function(cond, trueCallback, falseCallback) {
if(cond && typeof trueCallback === 'function') {
return trueCallback();
}
else if(!cond && typeof falseCallback === 'function') {
return falseCallback();
}
};
// Example usage
@rdp
rdp / gist:519744
Created August 11, 2010 20:54
rake fails until you delete the original .gemspec file
C:\installs\trunk3_installed>cd bin
C:\installs\trunk3_installed\bin>rake -T
C:/installs/trunk3_installed/lib/ruby/1.9.1/rubygems.rb:340:in `bin_path': can't find executable rake for rake-0.8.7 (Gem::Exception)
from C:/installs/trunk3_installed/bin/rake:19:in `<main>'
C:\installs\trunk3_installed\bin>cd ..
C:\installs\trunk3_installed>cat ./lib/ruby/gems/1.9.1/specifications/rake.gemspec
Gem::Specification.new do |s|
@stevenharman
stevenharman / Iso8601DateTimeBinder.cs
Created November 2, 2010 19:25
an asp.net-mvc Model Binder that respects the ISO 8601 standard. look it up, yo!
using System;
using System.Globalization;
using System.Web.Mvc;
namespace Zomg.Web.ModelBinders
{
public class Iso8601DateTimeBinder : DefaultModelBinder
{
public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
@mxriverlynn
mxriverlynn / .bashrc
Created November 25, 2010 17:08
.bashrc for MSysGit's "Git Bash Shell" (MinGW32 shell) with Pik
pik_info() {
version= pik info | awk '/full_version/ {print $2,$3}' | sed 's/\"//;s/\s/\-/'
printf "${version}"
}
function prompt {
local LIGHT_RED="\[\033[1;31m\]"
local LIGHT_GREEN="\[\033[1;32m\]"
local NO_COLOUR="\[\033[0m\]"
@prabirshrestha
prabirshrestha / iso8601Datetime.cs
Created April 5, 2011 16:43
ISO8601 Date Time helpers
public static class DateTimeHelpers
{
private static readonly string[] Iso8601Format = new[]
{
"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'",
@"yyyy-MM-dd\THH:mm:ssK"
};
//SortableDateTimePattern (ISO 8601)
public static string ToIso8601(DateTime value)
using System.Web;
namespace NetflixDemo
{
public class AppHarborHttpContextWrapper : HttpContextWrapper
{
private readonly HttpContext httpContext;
public AppHarborHttpContextWrapper(HttpContext httpContext) : base(httpContext)
{
@mattpodwysocki
mattpodwysocki / jsconf-eu-2011.md
Created October 1, 2011 13:40
JSConf.EU Slides
@alexburner
alexburner / gist:1406189
Created November 29, 2011 19:55
Turning PST / PDT unixtime stamps into UTC date objects
// unixtime stamps from server are PT, need to make them UTC
var getAdjustedDate = function ( unixtime ) {
if ( !unixtime ) { return new Date(); }
var date, dst, offset;
// create date object
if ( typeof unixtime === 'number' ) {
date = new Date( unixtime * 1000 );
} else if ( typeof unixtime === 'string' ) {
unixtime = parseInt( unixtime, 10 );
date = new Date( unixtime * 1000 );
@half-ogre
half-ogre / NuGet.targets.xml
Created February 22, 2012 04:22
A replacement for the NuGet.targets file that requires nuget.exe be on the path, so you don't have to commit it.
<?xml version="1.0" encoding="utf-8"?>
<!-- #### NOTE #### -->
<!-- To build with Mono's xbuild on bash, you must execute [`sudo install-nuget.sh`](https://gist.github.com/2595337) first. -->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
<!-- Windows specific commands -->
@mhinze
mhinze / exposeiis.ps1
Created February 22, 2012 14:39
Sample solutionscript to expose IIS
function global:ExposeIIS()
{
$config = [xml] ( get-content $env:IIS_USER_HOME/config/applicationhost.config )
# Add in new bindings for computer name
foreach($site in $config.configuration."system.applicationHost".sites.site)
{
foreach($bindings in $site.bindings)
{
# no need to add another binding for machine name if its exists