Skip to content

Instantly share code, notes, and snippets.

View vlucas's full-sized avatar

Vance Lucas vlucas

View GitHub Profile
$tags = array('link', 'script');
$tag_pattern = '#<\s*T\s+(.*)\s*(?:/>|>(.*)</T>)#Ui';
$matches = array();
// first assembling all work. The idea is that, if sorted by descending
// location offset, we can selectively remove tags.
//
// We'll need that to conditionally handle tags (like jTemplate's
// <script type="text/html" that should remain)
<?php
# app/Modules/Events/views/indexAction.html.php
?>
<div class="section recent-tags">
<h3>
Recent Tags
<span class="f-right"><a href="<?php echo $this->kernel->url('module', array('module' => 'Tags')); ?>" title="view more tags">View All</span>
</h3>
<?php
// Get tag cloud from Tags module
@vlucas
vlucas / get_price_spec.js
Created January 25, 2012 19:32
Parsing money out of text strings in various different given formats (Craigslist postings, Facebook wall posts, etc.)
function getPrice(str) {
if(str.indexOf('$') !== -1) {
// Dollar sign present - it always trumps other number values
var reg = /\$([\d,.]+)/g;
} else if(/(\d[\d.,]+)/.test(str)) {
// Digits with decimals found - more likely to be price than other number values
var reg = /(\d[\d.,]+)/g;
} else {
// Any numbers at all that are surrounded by spaces (fallback; worst accuracy)
var reg = /\s+([\d]+)\s+/g;
@vlucas
vlucas / gist:1802688
Created February 11, 2012 17:22
Mac OS X Architecture Flags
# x386 Architecture
export CFLAGS="-arch i386 $CFLAGS"
export CCFLAGS="-arch i386 $CCFLAGS"
export CXXFLAGS="-arch i386 $CXXFLAGS"
export LDFLAGS="-arch i386 $LDFLAGS"
# x64 Architecture
export CFLAGS="-arch x86_64 $CFLAGS"
export CCFLAGS="-arch x86_64 $CCFLAGS"
export CXXFLAGS="-arch x86_64 $CXXFLAGS"
@vlucas
vlucas / hack.sh
Created April 2, 2012 16:50 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
get('http://api.joind.in/v2.1/events/907')
expectJSONTypes({
name: String
start_date: String
end_date: String
description: String
href: String
attendee_count: Number
icon: String
tags: Array
frisby.create('Ensure each tweet has base attributes')
.get('https://api.twitter.com/1/statuses/user_timeline.json?screen_name=brightbit')
.expectStatus(200)
.expectHeaderContains('content-type', 'application/json')
.expectJSONTypes('*', {
id_str: String,
retweeted: Boolean,
in_reply_to_screen_name: function(val) { expect(val).toBeTypeOrNull(String); }, // Custom matcher callback
user: {
verified: Boolean,
{
"page":1,
"actions":{
"add":{
"url":"http://localhost:3000/events.json",
"method":"post",
"fields":{
"category_id":{
"type":"integer",
"length":null,
@vlucas
vlucas / budgets.json
Created June 18, 2012 21:33
Hypermedia API with "form"-like descriptions
{
"_links":{
"add":{
"title":"Add Budget",
"href":"http:\/\/localhost\/brightb.it\/budgetapp\/budgets",
"method":"post",
"parameters":{
"name":{
"type":"string",
"required":true
@vlucas
vlucas / gist:3976934
Created October 29, 2012 22:22 — forked from ericboehs/gist:3863345
PHP / MySQL Server (Ubuntu 12.04)
#!/usr/bin/env bash
###
# Run this script as root
###
# Setup variables for this script
USER_NAME=vlucas
USER_EMAIL=vance@vancelucas.com
SSH_PUBLIC_KEY="ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAxoQkUlUr+GcEpY1Its3mXFq/xi6yUgknxcSfGx0Yl25zo9nLl5UpeA+r0SmTfnu5oj674i+Ccx7NgwIkhGONXyKZaWyQf7jQZRa6sAMyETQ8QFbkprLCcF6LXJ9B1Khj16ZgXgcuSjMQKmbi8FA3iCcP5jGeT/02x5QhC5hXNPZafODwR5Xty559mLqsZ3LwzQZ4YaQDi4fnEDz7z4iA5+2Xo44de4ypmAmRBsOJZ0mgiRyClDEa0TVCctIXLeOt5OU76DE/IXuKHmtpwWiAI+c6ZNLmXeidrMQzhS6XfDwtTS0YMNnXn4aSSSJNhuvRAhCj9qjAXT1lV1QPb2P84Q== vance@vancelucas.com"