Skip to content

Instantly share code, notes, and snippets.

@samandmoore
samandmoore / file_a.dart
Created August 31, 2021 17:53
duplicate consts
const something = "";
#!/bin/bash
set -e
PROJECT_DIR="${CIRCLE_WORKING_DIRECTORY/#\~/$HOME}"
# Workaround old docker images with incorrect $HOME
# check https://github.com/docker/docker/issues/2968 for details
if [ "${HOME}" = "/" ]
then
@samandmoore
samandmoore / output.sh
Created April 26, 2017 20:57
output safety rubocop issues
$ rails c
Loading development environment (Rails 4.2.7.1)
irb(main):001:0> include ActionView::Helpers::OutputSafetyHelper
=> Object
irb(main):002:0> raw "foo"
=> "foo"
irb(main):003:0> thing = raw "foo"
=> "foo"
irb(main):004:0> thing.class
=> ActiveSupport::SafeBuffer

Keybase proof

I hereby claim:

  • I am samandmoore on github.
  • I am samandmoore (https://keybase.io/samandmoore) on keybase.
  • I have a public key ASDPb_dntgaot_-UkwH9ffIECYnlcW-Njurs5AjRvYebzgo

To claim this, I am signing this object:

@samandmoore
samandmoore / baseRouteUsage.js
Last active August 29, 2015 14:15
beforeRender
var PortfolioRoute = BaseRoute.extend({
prepare: function() {
this.promise = …;
return this.promise;
},
render: function() { … },
error: function() { … }
});
@samandmoore
samandmoore / java solution to var
Created May 15, 2013 16:56
java doesn't have var, so if you want to type less, you have to create a static factory...
// problem
Map<String, List<String>> map = new HashMap<String, List<String>>();
// --------------------------------------------------
// Java solution
public static <K, V> HashMap<K, V> newHashMap() {
return new HashMap<K, V>();
}
<table id="posts">
<thead>
<tr>
<th>ID</th>
<th>Title</th>
<th>Date Created</th>
<th>Published</th>
</tr>
</thead>
<tbody>
[Fact]
public void UrlWithinQuotes()
{
//arrange
var message = "This is a sentence with quotes and a url ... see \"http://foo.com\"";
HashSet<string> extractedUrls;
//act
var result = TextTransform.TransformAndExtractUrls(message, out extractedUrls);
@samandmoore
samandmoore / gist:3139587
Created July 18, 2012 23:05
Default Sort for with Lambda
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
namespace ConsoleApplication1
{
class Program
{
public static DefaultSort GetDefaultSort<TModel, TProperty>(Expression<Func<TModel, TProperty>> expression, SortDirection direction)
{
return new DefaultSort(EvaluateExpression(expression), direction);
}
private static string EvaluateExpression(LambdaExpression expression)
{
var memberExpression = expression.Body as MemberExpression;
return memberExpression == null ? null : memberExpression.Member.Name;
}