Skip to content

Instantly share code, notes, and snippets.

View mattneary's full-sized avatar

Matt Neary mattneary

View GitHub Profile
@mattneary
mattneary / unorder_search.sql
Last active December 29, 2015 08:09
UPDATE queries
'x LIKE "%'+'a b c'.gsub(/\s/, '%" AND x LIKE "%')+'%"'
@mattneary
mattneary / docs.md
Created December 4, 2013 17:22
API docs

Group (appname: auth)

  • /api/group/ - returns a list of first 20 groups
  • /api/group/?start=0 - returns a list of first 20 groups
  • /api/group/?start=10 - returns a list of 20 groups starting from 10th group
  • /api/group/?start=10&count=30 - returns a list of 30 groups starting from 10th group
    • "count" is the number of items to be returned, from the position equal to "start" value.
@mattneary
mattneary / add.sh
Last active August 29, 2015 13:56
Add SSH Key
#!/bin/bash
# Run locally
cat ~/.ssh/id_rsa.pub | ssh [email protected] 'cat >> /etc/ssh/watterson/authorized_keys'
ssh [email protected] 'sudo service ssh restart'
@mattneary
mattneary / ClsSensorPlaneIntersector.cs
Last active August 29, 2015 14:03
Bezier surface intersection with a plane.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Kiss.Effigy.code {
public class ClsSensorPlaneIntersector {
public Vector Origin;
public Func<float, float, Vector> Parametric;
public float Plane;
public class ClsSurfacePlaneIntersector : ClsIntersector {
public int Precision = 100;
public Vector3 FindPointIntersection(Func<float, Vector3> surfaceSlice, float elevation, float min, float max) {
var mid = (max + min) / 2;
var minE = surfaceSlice(min).Z;
var midE = surfaceSlice(mid).Z;
var maxE = surfaceSlice(max).Z;
if (FuzzyEqual(elevation, midE) || FuzzyEqual(mid, max)) {
return surfaceSlice(mid);
}
@mattneary
mattneary / fact.swift
Created July 30, 2014 15:24
Nested Recursive Functions Broken in Swift
func run() -> Int {
func fact(n : Int) -> Int {
return n == 0 ? 1 : n * fact(n-1)
}
return fact(3)
}
println(run())
// Gives the following error:
// Instruction does not dominate all uses!
@mattneary
mattneary / ScheduleFinder.md
Last active August 29, 2015 14:05
A programming exercise.

Note that each command is preceded by $ to distinguish it from output; do not type the $.

We start with the data file.

$ cat data.txt
4|55504|214052
7|37107|214052
6|45206|214052
#!/bin/bash
curl -s \
-d '{
"user": {
"email": "[email protected]",
"password": "password",
"password_confirmation": "password",
"profile_attributes": {
"gender": "m",
"name": "Matt Neary",
@mattneary
mattneary / kensho.js
Last active August 29, 2015 14:20
Interview
var marked = {};
function markPoint(matrix, x, y) {
marked[x+","+y] = true;
}
function isPointMarked(matrix, x, y) {
return marked[x+","+y];
}
function findNeighbors(matrix, x, y) {
return [-1, 0, 1].map(function (i) {
return [-1, 0, 1].map(function (j) {
@mattneary
mattneary / poem.txt
Created May 1, 2015 02:39
Intimations of Immortality from Recollections of Early Childhood
Intimations of Immortality from Recollections of Early Childhood
By Wordsworth
I
THERE was a time when meadow, grove, and stream,
The earth, and every common sight,
To me did seem
Apparelled in celestial light,
The glory and the freshness of a dream.
It is not now as it hath been of yore;--