Skip to content

Instantly share code, notes, and snippets.

View tjweir's full-sized avatar

Tyler Weir tjweir

View GitHub Profile
In some cases the type of a method's result may depend on the type of its arguments.
To accurately express the signatures of such methods one may use parametric polymorphism.
A parametrically polymorphic method signature introduces one or more formal type arguments
which can be used throughout the signature and the method body. When the message is sent,
the actual types will be inferred and replace the formal type arguments in the signature.
As an example, consider the signature of -[NSArray[T] mapArrayUsingBlock:]
- (NSArray[X]) mapArrayUsingBlock: (X (^)(T obj) block;
The type term X def introduces a type argument X, which will be inferred to be the type returned
/**
* Return a block that computes the next value and returns the next stream instance.
*/
static PLStreamRemainingBlock NextStream (NSNumber *current) {
/** Create a block which will return the next stream value */
PLStreamRemainingBlock f = ^{
PLStreamRemainingBlock remaining;
NSNumber *value;
/* Create the new stream */
import se.scalablesolutions.akka.serialization.Serializer
import se.scalablesolutions.akka.actor.Actor
import com.rabbitmq.client.ConnectionParameters
object ExampleSession {
import AMQP._
val SERIALIZER = Serializer.Java
val CONFIG = new ConnectionParameters
val HOSTNAME = "localhost"
val PORT = 5672
//
// NSObject+BlockObservation.h
// Version 1.0
//
// Andy Matuschak
// [email protected]
// Public domain because I love you. Let me know how you use it.
//
#import <Cocoa/Cocoa.h>
(ns alandipert.minihttpd
(:use [clojure.contrib.duck-streams :only (reader writer read-lines spit to-byte-array)]
[clojure.contrib.str-utils :only (re-split str-join)])
(:import (java.net ServerSocket Socket InetAddress URLDecoder)
(java.io File)))
(def codes {200 "HTTP/1.0 200 OK"
404 "HTTP/1.0 404 Not Found"})
(def mimes {"css" "Content-type: text/css"
@tjweir
tjweir / foo.m
Created October 17, 2009 17:10 — forked from tomjadams/foo.m
// OLD
- (NSDictionary *)parsePerks:(NSArray *)perks {
NSMutableArray *convertedPerks = [NSMutableArray arrayWithCapacity:[perks count]];
for (NSDictionary *perk in perks) {
PLPerk *convertedPerk = [[PLPerk alloc] initWithProgramName:[perk objectForKey:@"program_name"]
shortDescription:[perk objectForKey:@"perk_title"] longDescription:[perk objectForKey:@"perk_desc"]
location:[self parseLocation:[perk objectForKey:@"locations"]]];
[convertedPerks addObject:convertedPerk];
[convertedPerk release];
package sandbox
import actors.Actor
import org.apache.log4j.Logger
object getter extends Actor {
val logger = Logger.getLogger("Actor")
def act() {
while (true) {
module Rack
class ZombieShotgun
ZOMBIE_AGENTS = [
/FrontPage/,
/Microsoft Office Protocol Discovery/,
/Microsoft Data Access Internet Publishing Provider/
].freeze
ZOMBIE_DIRS = ['_vti_bin','MSOffice','verify-VCNstrict','notified-VCNstrict'].to_set.freeze
-module(rabbit_test).
-compile(export_all).
-include_lib("rabbitmq_erlang_client/include/amqp_client.hrl").
-define(X, <<1,2,3,4>>).
-define(RoutingKey, <<5,6,7,8>>).
-define(Q, <<9,10,11,12>>).
%% -------------------------------------
def bid(xhtml: NodeSeq): NodeSeq = {
if(!Customer.loggedIn_?){
S.warning("You must be logged in to bid on auctions.")
NodeSeq.Empty
}
else {
var amountBox: Box[String] = Empty
def submit = {
for(ass <- amountBox ?~ "Amount not entered";