This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Change SEARCH_ROOT to point to proper directory. | |
# USAGE: ruby grepword.rb <word> | |
SEARCH_ROOT = "/path/to/books/directory" | |
word = Regexp.new(ARGV[0].encode('utf-8', 'external')) | |
def clean line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
var schedule_dialog = $("#appt-dialog") | |
schedule_dialog.dialog({ | |
autoOpen: false, | |
modal: true, | |
minWidth: 600, | |
minHeight: 200 | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Model | |
@user.should have(1).error_on(:username) # Checks whether there is an error in username | |
@user.errors[:username].should include("can't be blank") # check for the error message | |
#Rendering | |
response.should render_template(:index) | |
#Redirecting | |
response.should redirect_to(movies_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ElevatorRequest(object): | |
def __init__(self, from_floor, to_floor): | |
self.from_floor = from_floor | |
self.to_floor = to_floor | |
def __cmp__(self, other): | |
return self.from_floor == other.from_floor | |
def __str__(self): | |
return "<ElevatorRequest: From %d to %d>" % (self.from_floor, self.to_floor) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename T> | |
class DoubleBufferedMap | |
{ | |
private: | |
size_t m_width; | |
size_t m_height; | |
T * m_front; | |
T * m_back; | |
public: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class QuadTree | |
{ | |
private: | |
static const int MAX_ENTITIES = 20; | |
std::vector<Entity *> m_entities; | |
sf::Vector2i m_position; | |
sf::Vector2i m_size; | |
QuadTree * m_nodes; | |
int getIndex(const Entity * e) const |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
typedef struct tokenize_state_t { | |
const char * position; | |
} tokenize_state_t; | |
int check_delim(char c, const char * delim) { | |
for (const char * cur = delim; *cur != '\0'; ++cur) { | |
if (c == *cur) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import random | |
from collections import defaultdict | |
class MarkovPrefix(object): | |
def __init__(self, n): | |
if n < 1: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// File format: | |
// | |
// Roughly based on INI style configs. | |
// | |
// 'Key=Value' pairs, one pair per line. If a line contains more than one '=', | |
// the first is taken to be the deliminator and the rest are included as part | |
// of the value string. | |
// | |
// A line containing a key but no value (i.e., no '='), will be parsed as an | |
// entry with an empty value string. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$mingwPath = "C:\MinGW\bin" # Replace with MinGW path from $ENV:PATH | |
$pathArray = $ENV:PATH.Split(";") | |
$newPath = "" | |
Foreach ($p in $pathArray) { | |
if (!$p.Equals($mingwPath)) { | |
$newPath += ";" | |
$newPath += $p | |
} | |
} |
OlderNewer