Skip to content

Instantly share code, notes, and snippets.

@josgraha
josgraha / gist:4121930
Created November 20, 2012 23:18 — forked from swannodette/gist:4120545
Possible syntaxes for flexible unifier w/ multi-lvar constraints
;;Support for simple constraints on lvars during unification was added in 76fd4d7c:
;;
;; https://github.com/clojure/core.logic/commit/76fd4d7c155161d74ad5cd8d87955148eece1fe0
;;
;;but these constraints apply to a single lvar only.
;;The unifier could support more general constraints if it accepted an explicit predicate function.
;;For instance, given this `data-numeric?` predicate and `spec` data:
(defn data-numeric? [data dimension]
@josgraha
josgraha / ObjectFilter.cs
Last active December 18, 2015 11:29
filter object enumeration
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ObjectFilter
{
interface IObjectTest<T>
{
bool test(T o);
year|cnty_description|county_cd_fk|budget_unit_type|unit_code|unit_name|afr_unit_type|Fund_code|unit_fund_number|unit_fund_name|disburse_class_code|disburse_class_name|vendor_name|vendor_disburse_code|amount
2012|Adams|01|2|0001|BLUE CREEK TOWNSHIP|7|102087|1|Fire Fund|300|Services and Charges|Monroe Fire Department|DT03|3000.00
2013|Adams|01|2|0001|BLUE CREEK TOWNSHIP|7|102087|1|Fire Fund|300|Services and Charges|Monroe Fire Department|DT03|3000.00
2012|Adams|01|2|0001|BLUE CREEK TOWNSHIP|7|102087|1|Fire Fund|300|Services and Charges|Berne Fire Department|DT03|6604.16
2011|Adams|01|2|0001|BLUE CREEK TOWNSHIP|7|102087|1|Fire Fund|300|Services and Charges|Monroe Volunteer Fire Department |DT03|2354.22
2013|Adams|01|2|0001|BLUE CREEK TOWNSHIP|7|102087|1|Fire Fund|300|Services and Charges|City of Berne|DT03|7080.16
2011|Adams|01|2|0001|BLUE CREEK TOWNSHIP|7|102087|1|Fire Fund|300|Services and Charges|Berne Fire Department|DT03|6380.83
2013|Adams|01|2|0001|BLUE CREEK TOWNSHIP|7|101008|2|Township|100|Personal Serv
@josgraha
josgraha / pom.xml
Last active August 29, 2015 14:06 — forked from codahale/pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>my-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<!-- none yet -->
define(function(require) {
var System = {};
System.Events = require("./core/events"),
System.Strategy = require("./core/strategy"),
System.Analytics = require("./core/analytics"),
System.Indicators = require("./core/indicators"),
System.Market = require("./rules/market"),
System.Timeseries = require("./data/timeseries"),
System.Symbols = require("./pairs/symbols"),
System.Portfolio = require("./manager/portfolio");
@josgraha
josgraha / index.html
Last active August 29, 2015 14:23 — forked from anonymous/index.html
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<script src="https://raw.githack.com/CrossEye/ramda/master/ramda.js"></script>
<script src="http://looprecur.com/hostedjs/pointfree.browser.js"></script>
<script src="http://looprecur.com/hostedjs/monoids.js"></script>
<script src="http://looprecur.com/hostedjs/maybe.js"></script>
@josgraha
josgraha / husband_wife_crossing_solution.md
Last active August 29, 2015 14:24
Husband Wife Crossing Problem

solved by: @sprimerano

mv | cross | left | right | return | left | right --- | --- | --- | --- |--- | --- | --- | ---

| -> xy | {A,B,Cz} | {x,y} | <- x | {Ax,B,Cz} | {x}

| -> xz | {A,B,C} | {x,y,z} | <- x | {Ax,B,C} | {y,z}

| -> BC | {Ax} | {By,Cz} | <- By | {Ax,By} | {Cz}

| -> AB | {x,y} | {A,B,Cz} | <- z | {x,y,z} | {A,B,C}

| -> xy | {z} | {Ax,By,C} | <- x | {x,z} | {A,By,C}

| -> xz | {} | {Ax,By,Cz}

@josgraha
josgraha / problem.md
Last active August 29, 2015 14:24
Magic Squares Problem

Description

Find a 4×4 magic square consisting of 16 different positive semiprimes less than 100. A semiprime is a positive integer with exactly two, not necessarily different, prime factors. (For example, both 21 = 3×7 and 25 = 52 are semiprimes.) In a magic square, the entries in each column, row, and major diagonal have the same sum (known as the magic sum). We want a magic square for which, in addition, the four center entries, the four corners, and each of the four quadrants also exhibit the same magic sum, making a total of 16 ways to get the magic sum. We want the square with the smallest magic sum for such a square. Present your answer as four rows of four integers each.

Hints

Primes up to 100

2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97

Semiprimes up to 100

# to install the latest stable version:
brew install scala --with-docs
# to install scala-2.10:
brew install https://raw.github.com/gist/4340744/scala.rb --with-docs
# to switch versions (from https://github.com/mxcl/homebrew/wiki/External-Commands):
brew switch scala 2.9.2
brew switch scala 2.10.0
@josgraha
josgraha / README.md
Last active July 10, 2016 14:30
Simple react problem

Problem:

Create a React class or set of classes to display a list of images so they space out and align evenly no matter how wide the screen resolution is. Example:

| [image]   [image]   [image] |
| [wide image]   [wide image] |
| [image]   [image]   [image] |

Bonus: