Skip to content

Instantly share code, notes, and snippets.

View mikebaldry's full-sized avatar

Michael Baldry mikebaldry

View GitHub Profile
scope :dashboard_active, includes(:media_plan_line)
.where(["((media_plan_lines.start_at <= ? AND media_plan_lines.end_at >= ?)
OR
(DATEDIFF(CURDATE(), media_plan_lines.end_at) <= 10)) AND NOT media_plan_lines.status = ?",
Date.today, Date.today, "pipeline"])
describe "Conditional matching" do
it "should understand binary/unary operators correctly, given the predecate to decide" do
subject = Lexr.that {
ignores /\s+/ => :whitespace
legal_place_for_binary_operator = lambda { |prev| [:addition,
:subtraction,
:multiplication,
:division,
:left_parenthesis,
To run: ./image_editor
To run tests: #run with python -m unittest app_tests.TestImage
------original challenge------
Coding challenge
Graphical editors allow users to edit images in the same way text editors let us modify documents. Images are represented as an M x N array of pixels with each pixel given colour.
Produce a program that simulates a simple interactive graphical editor.
Coding challenge
Graphical editors allow users to edit images in the same way text editors let us modify documents. Images are represented as an M x N array of pixels with each pixel given colour.
Produce a program that simulates a simple interactive graphical editor.
Input
The input consists of a line containing a sequence of commands. Each command is represented by a single capital letter at the start of the line. Arguments to the command are separated by spaces and follow the command character.
@mikebaldry
mikebaldry / gist:2006495
Created March 9, 2012 13:25
always doing a GET?
$.ajax({
url: "/oasis/incoming_call",
dataType: "json",
data: {
id: leadId,
contact: {
call_id: callId,
campaign_name: campaignName
}
},
@mikebaldry
mikebaldry / gist:1884577
Created February 22, 2012 12:16
brew install sox
Warning: It appears you have Macports or Fink installed
Software installed with other package managers causes known problems for
Homebrew. If formula fail to build uninstall Macports/Fink and reinstall any
affected formula.
Also installing dependencies: libogg, libvorbis, lame, flac, libao, mad
==> Downloading http://downloads.xiph.org/releases/ogg/libogg-1.2.2.tar.gz
######################################################################## 100.0%
==> ./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/libogg/1.2.2
==> make
==> make install
@mikebaldry
mikebaldry / gist:1854050
Created February 17, 2012 15:35
merging 2 objects
mergeObjects: (obj1, obj2) ->
obj3 = {}
for attrName in obj1
obj3[attrName] = obj1[attrName]
for attrName in obj2
obj3[attrName] = obj2[attrName]
obj3
@mikebaldry
mikebaldry / gist:1519546
Created December 25, 2011 17:49
My Makefile
CXX=g++
CXXFLAGS=-Wall -gdwarf-2 -O2 -g -I /usr/local/boost_1_48_0
LDFLAGS=-L/usr/local/boost_1_48_0/stage/lib -lboost_signals -lboost_thread -lboost_system -lboost_program_options
svr: main.o server.o io_service_pool.o connection.o command_parser.o
$(CXX) -o svr $(LDFLAGS) main.o server.o io_service_pool.o connection.o command_parser.o
%: %.cpp
$(CXX) $(CXXFLAGS) $^ -o $@
@mikebaldry
mikebaldry / gist:1519173
Created December 25, 2011 12:26
Why would resulting_command need to be declared, when declaring it?
command_parser.cpp:13: error: ‘resulting_command’ was not declared in this scope..
command& command_parser::parse(const std::string& command) {
13: command* resulting_command = NULL;
std::vector<std::string> parts;
boost::split(parts, command, boost::is_any_of(" "));
std::string cmd = parts.at(0);
boost::to_upper(cmd);
parts.erase(parts.begin());
@mikebaldry
mikebaldry / gist:1437786
Created December 6, 2011 10:57
Query optimisation..
SELECT c.contract_id, csc1.changed_status
FROM contract c
LEFT
JOIN contract_status_change csc1
ON csc1.contract_status_change_id =
( SELECT csc2.contract_status_change_id
FROM contract_status_change csc2
WHERE csc2.contract_id = c.contract_id
ORDER
BY csc2.date_changed DESC