Skip to content

Instantly share code, notes, and snippets.

<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.google.com");
}
</script>
-module(etap_t_001).
-export([start/0]).
start() ->
etap:plan(8),
etap_application:start_ok(inets, "Application inets starts"),
etap_web:simple_200("http://0.0.0.0:8000/", "GET / returns 200."),
RequestPostDB = etap_web:build_request(post, "http://0.0.0.0:8000/_db", [], [<<"test_cache">>]),
RequestPostDB:status_is(201, "POST for successful create returns 201."),
RequestDeleteDB = etap_web:build_request(delete, "http://0.0.0.0:8000/_db",[],[<<"test_cache">>]),
swap(Bin, Original, New) ->
swap(Bin, erlang:byte_size(Original), Bin, Original, New, 0).
swap(BinOrig, OriginalLen, Bin, Original, New, Acc) ->
case Bin of
<<Original:OriginalLen/binary, Right/binary>> ->
OtherRepl = swap(Right, Original, New),
<<Left:Acc/binary,_/binary>> = BinOrig,
<<Left/binary, New/binary, OtherRepl/binary>>;
%couchdb connection information
-record(couch_config,{host="0.0.0.0",port=5984,db="mydatabase"}).
update_couchdb_property(OrigProps, {Key, _Value} = ChngProp) when is_list(OrigProps), is_tuple(ChngProp) ->
case lists:keymember(Key, 1, OrigProps) of
true ->
NewProps = lists:keyreplace(Key, 1, OrigProps, ChngProp);
false -> %append
NewProps = lists:append(OrigProps,[ChngProp])
end,
#include <stdio.h>
#include <stdlib.h>
int
main(int argc, char** argv) {
char protein[4] = "ACGT";
int size = atoi(argv[1]);
int i = 0;
int pos = 0;
for(i; i < size; ++i) {
#!/bin/sh -ex
# CouchDBX-Core-Builder
# Downloads, Install Erlang & CouchDB into a package
# Copyright 2009 Jan Lehnardt <jan@apache.org>
# Apache 2.0 Licensed
# customise here:
# use full svn path for branches like "branches/0.9.x"
@bradfordw
bradfordw / rlsp.rb
Created November 9, 2009 14:07 — forked from h0rs3r4dish/rlsp.rb
#!/usr/bin/ruby
RLSP_VERSION = "1.4.1"
class Lambda
attr_accessor :args, :body
def initialize(args=[],body="")
@args = (args.class == Array) ? args : [args]
@body = body
end
def authorized?
model = Kernel.const_get(params[:controller].classify)
model.first(:conditions => {:_id => current_user._id}).is_a?(model)
end
Loading production environment (Rails 2.3.4)
>> u = User.new
=> #<User contribution_count: nil, crypted_password: nil, reset_password_code_until: nil, _id: nil, username: nil, reset_password_code: nil, email: nil>
>> u.valid?
NameError: uninitialized constant MongoMapper::EmbeddedDocument::ClassMethods::ObjectId
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/mongo_mapper-0.6.1/lib/mongo_mapper/embedded_document.rb:66:in `object_id_key?'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/mongo_mapper-0.6.1/lib/mongo_mapper/finder_options.rb:63:in `to_mongo_criteria'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/mongo_mapper-0.6.1/lib/mongo_mapper/finder_options.rb:60:in `each_pair'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/mongo_mapper-0.6.1/lib/mongo_mapper/finder_options.rb:60:in `to_mongo_criteria'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/mongo_mapper-0.6.1/lib/mongo_mapper/finder_options.rb:38:in `criteria'
-module(histo).
-compile(export_all).
-define(WORDS,[ "a", "at", "red", "green", "dog"]).
parse_input(Input) ->
lists:foldl(fun(Letter, D) -> dict:update(Letter, fun(N) -> N + 1 end, 1, D)
end, dict:new(),
[L || L <- Input]).
start_find(InputHisto) ->