Skip to content

Instantly share code, notes, and snippets.

@benash
benash / subsetSum.js
Last active July 5, 2016 16:04
Naive Javascript subset sum
// Given a list of numbers a and a number n,
// return the subset of a that sums to n,
// or return false if no such subset exists
function subsetSum(a, n) {
if (a.length === 0) return false
const el = a[0]
if (el === n) return [ el ]
const rest = a.slice(1)
<Chain>
<PackageGroupRef Id="NetFx20Web"/>
<!-- more packages here -->
</Chain>
<!-- . . . -->
<Fragment>
<PackageGroup Id="NetFx20Web">
<ExePackage InstallCondition="NOT VersionNT64 AND VersionNT &lt;&gt; v6.1"
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Bundle Name="MyBootstrapper" Version="1.0.0.0" Manufacturer="" UpgradeCode="2d23a9d5-e503-4520-bfd7-07038bc8423b">
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" />
<Chain>
<!-- TODO: Define the list of chained packages. -->
<!-- <MsiPackage SourceFile="path\to\your.msi" /> -->
</Chain>
</Bundle>
class UserPartial
constructor: (@parent) ->
Object.defineProperties @prototype,
userId:
get: -> @parent.getAttribute(‘data-id')
get userId() {
return this.parent.getAttribute(‘data-id’);
}
function UserPartial(parent) {
this.parent = parent;
// . . .
this.userId = this.parent.getAttribute(‘data-id’);
};
function UserPartial(parent) {
this.parent = parent;
this.firstName = this.parent.element(By.css('.app-first-name'));
this.lastName = this.parent.element(By.css('.app-last-name'));
this.username = this.parent.element(By.css('.app-username'));
};
function InfoPage() {
this.users = element.all(By.css('.app-user'));
};
@benash
benash / login.js
Created December 13, 2014 21:23
A Protractor page object and test
var LoginPage = function() {
this.userInput = element(by.model('username'));
this.passwordInput = element(by.model('password'));
this.loginButton = element(by.css('.app-login'));
this.get = function() {
browser.get('#/login');
};
this.login = function(username, password) {
ls -lUd */ | awk '{print $9}' | while read -r i; do cd $i &> /dev/null; git remote -v 2> /dev/null | head -1; cd ..; done
@benash
benash / history
Last active August 29, 2015 14:06
history | sed 's/ [ ]*/ /g' | cut -d' ' -f 3- | sort | uniq -c | sort -nr | head -10
507 git st
167 git diff
150 git add .
131 git ci
109 git lg
91 ls
72 git pull
54 mvim
50 git push