Skip to content

Instantly share code, notes, and snippets.

View tyler569's full-sized avatar

Tyler Philbrick tyler569

  • San Francisco, USA
View GitHub Profile
#![feature(io)]
use std::net::{TcpStream};
use std::io::{BufRead, BufReader, Write, stdout};
//mod parser;
fn main() {
let name = "irc.freenode.net:6667";
struct Foo<'a> {
a: String,
b: &'a str,
}
impl<'a> Foo<'a> {
fn new() -> Foo<'a> {
Foo { a: String::new(), b: "" }
}
getAppend :: String -> IO String
getAppend x = getLine >>= return . (++ x)
main :: IO ()
main = getAppend " World!" >>= putStrLn
class Color(prefix: String) {
def apply(text: String): String = {
prefix + text
}
}
object Color {
val RED = new Color("&c")
val BLUE = new Color("&1")
@tyler569
tyler569 / irc-minimal.scala
Last active August 29, 2015 14:25
Very minimal IRC connection in scala
import java.net._
import java.io._
import scala.io._
class IRC(server: String, nick: String, user: String, channel: String) {
val port = 6667
val host = InetAddress.getByName(server)
val sock = new Socket(host, port)
lazy val in = new BufferedSource(sock.getInputStream())
val out = new PrintStream(sock.getOutputStream())
import java.io.PrintWriter
import java.net.{InetAddress, Socket}
import scala.io.BufferedSource
object Main {
def main(args: Array[String]) = {
val conn = new Socket(
InetAddress.getByName("irc.openredstone.org"),
6667
trait AstElem[+T] {
def eval(): T
}
class LispFunction[-T, +R](f: List[T] => R) {
def apply(l: List[AstElem[T]]): R = {
f(l.map(_.eval()))
}
}
package main
import (
// "errors"
"fmt"
)
type Stack []int
func (s *Stack) Put(elem int) {
module Lib where
import Network
import Data.List
import System.IO
import Control.Arrow
import Control.Monad.Reader
import Control.Exception
import Text.Printf
#include <stdio.h>
#define string int
#define begin {
#define end }
#define return(x) printf("%s", x); return 0;
string main(int argc, char **argv)
begin