Skip to content

Instantly share code, notes, and snippets.

View sghill's full-sized avatar

Steve Hill sghill

  • Netflix
  • SF Bay Area
View GitHub Profile

Keybase proof

I hereby claim:

  • I am sghill on github.
  • I am sghill (https://keybase.io/sghill) on keybase.
  • I have a public key whose fingerprint is 4CC0 A8B3 8CAF E5EB 66D8 EF59 9EC2 5311 1CC1 04B2

To claim this, I am signing this object:

import android.support.v4.app.Fragment;
public interface Validatable {
boolean isValid();
}
// does not compile
List<T extends Fragment & Validatable> validatableFragments2;
@sghill
sghill / v1-ItemsColumn.java
Last active December 17, 2015 15:29
Defining a public static class full of strings and concatenating for Android's SQLite is frustrating, and I don't think I want to bother with a full ORM. It'd just be nice if something would help me with the mundane stringbuilding a bit more. It'd be better if I couldn't build a list of values to insert/update that didn't match the corresponding…
package com.sgrailways.typeddb;
public enum ItemsColumn implements Column {
SKU(SQLite3DataType.TEXT),
CENTS(SQLite3DataType.INTEGER),
THUMBNAIL(SQLite3DataType.BLOB);
private final SQLite3DataType dataType;
ItemsColumn(SQLite3DataType dataType) {
@sghill
sghill / knockout_login_form.html
Last active December 17, 2018 09:41
Sample login form with KnockoutJS (and tests!)
<!-- assume Knockout and ViewModel file referenced -->
<form action="/sessions" method="POST">
<input type="text" name="username" data-bind="value: username"><br />
<input type="password" name="password" data-bind="value: password"><br />
<input type="submit" value="sign in" data-bind="enable: buttonEnabled">
</form>
<!-- assume jQuery and standalone js file referenced -->
<form action="/sessions" method="POST">
<input id="username" type="text" name="username"><br />
<input id="password" type="password" name="password"><br />
<input id="login-button" type="submit" value="sign in">
</form>
//assume: List<Sku> skusWithDuplicates
List<Sku> skusWithUniqueIds = new ArrayList<Sku>();
List<SkuId> skuIdsWeHaveSeenBefore = new ArrayList<SkuId>();
for(Sku sku : skusWithDuplicates) {
if(!skuIdsWeHaveSeenBefore.contains(sku.getId())) {
skusWithUniqueIds.add(sku);
}
}
// parent build.gradle
subprojects {
repositories {
ivy {
layout 'maven'
url 'path://to/my/maven/repo'
}
}
}
@sghill
sghill / detect_mongo_version.sh
Last active December 11, 2015 06:19
Detect in a shell script if you're running the right mongo version. Helpful when using mongodump, whose dump format changed to be unusable by earlier versions of mongod. see: http://docs.mongodb.org/manual/reference/mongodump/
if [[ -z $(mongo --version | grep '2.0.1') ]]; then
echo "expected 2.0.1, got $(mongo --version)"
exit 1
else
echo "we have the right version"
fi
folders = [
{:state => 'MI', :total => 50, :color => 'blue', :good => true},
{:state => 'AR', :total => 50, :color => 'green', :good => true}
]
params = {:state => "MI", :total => 50}
folders.select {|f| params.keys.all? {|k| f[k] == params[k] } }
# => [{:state=>"MI", :total=>50, :color=>"blue", :good=>true}]
params2 = { :color => "green" }
@sghill
sghill / FetchJobsButton.js
Created December 8, 2012 02:46
Jenkins Build Monitor in Enyo MVC
(function () {
enyo.kind({
name: "FetchJobsButton",
controller: "JobsController",
components: [
{name: "fetchButton", kind: "onyx.Button", content: "Fetch JRuby Jobs",
classes: "done-button", ontap: "fetchJobs"}
]
});
}());