Skip to content

Instantly share code, notes, and snippets.

View iamjwc's full-sized avatar

Justin Camerer iamjwc

  • LimeWire, LLC
  • New York City
View GitHub Profile
# This script demonstrates an issue with MongoMapper's #update_attributes!.
# Should call $set, but instead, just overwrites the entire doc.
#
# Script outputs:
#
# doc[:one] # => "uno"
# doc[:two] # => nil
class Doc
include MongoMapper::Document
@iamjwc
iamjwc / blownmind.rb
Created April 11, 2011 18:24
my mind is blown...
require 'sinatra'
before do
halt 200, {'Content-Type' => 'text/plain'}, "didnt match and it doesnt matter"
end
get '/hey' do
"hey!"
end
@iamjwc
iamjwc / before-filter-test.rb
Created April 7, 2011 20:29
Using url params in before filters
require 'sinatra'
before do
params[:thing] = params[:thing].uppercase
end
get '/:thing' do
"You said '#{params[:thing]}'"
end
Move =
move: (modelOrIndex, endIndex) ->
if typeof modelOrIndex == "number"
this.__moveIndexTo__(modelOrIndex, endIndex)
else
this.__moveModelTo__(modelOrIndex, endIndex)
__moveModelTo__: (model, endIndex) ->
this.__moveIndexTo__ _.indexOf(this.models, model), endIndex
// ==========================================================================
// Project: Todos.TaskDataSource
// Copyright: ©2010 My Company, Inc.
// ==========================================================================
/*globals Todos */
/** @class
(Document Your Data Source Here)
class HomeApp < Sinatra::Base
get "/" do
"Hello World!"
end
end
My::Application.routes.draw do |map|
match "/en", :to => HomeApp
end
<!doctype html>
<html>
<head>
<title></title>
<!-- Meta Info -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
// [~]$ g++ isLocalhost.cpp -o isLocalhost && ./isLocalhost 127.0.0.1 google.com localhost
// isSlocalhost(127.0.0.1) = 1
// isSlocalhost(google.com) = 0
// isSlocalhost(localhost) = 1
// isLocalhost(127.0.0.1) = 1
// isLocalhost(google.com) = 0
// isLocalhost(localhost) = 1
#include <netdb.h>
<!doctype html>
<html>
<head>
<title></title>
<!-- Meta Info -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<?xml version="1.0" encoding="iso-8859-1"?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<style>
div {
height: 1000px;
}
body {
background-color: #eaeaea;