Skip to content

Instantly share code, notes, and snippets.

View seanlilmateus's full-sized avatar

Mateus seanlilmateus

View GitHub Profile
@gkbrk
gkbrk / dict_server.rs
Created August 25, 2015 19:01
Dictionary server in Rust.
use std::io::prelude::*;
use std::net::{TcpListener, TcpStream};
use std::io::BufReader;
use std::thread;
use std::fs::File;
fn get_definitions(word: String) -> Vec<String>{
let mut dict = File::open("dict.txt").unwrap();
let mut reader = BufReader::new(dict);
let mut matches: Vec<String> = Vec::new();
//! Leveraging tuples to make a statically typed, concatenative EDSL in Rust.
//!
//! I'm not sure how practical it really is – Rust's syntax can make it a little
//! hard to read, but it's fun to play around with it. The neat thing is how
//! little copying occurs. Everything is moved in and out by-value in a pipeline.
//!
//! Thanks goes to [Tekmo on reddit](http://www.reddit.com/r/programming/
//! comments/1zzom4/using_functionlength_to_implement_a_stack_language/cfyibsr)
//! for the idea.
//!
@intrepidmatt
intrepidmatt / gist:d8209e4fa1f7727568ac
Created June 3, 2014 14:58
Swift language headers
operator infix ^= {
}
operator infix *= {
}
operator infix * {
}
operator infix % {
#!/Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -i -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
import Foundation
class JSON {
struct Path: Printable {
enum Element {
case Index(Int)
case Key(String)
@jonlipsky
jonlipsky / TouchWindow.cs
Created August 21, 2014 18:08
TouchWindow.cs
using System;
using System.Collections.Generic;
using System.Drawing;
using MonoTouch.CoreGraphics;
using MonoTouch.UIKit;
using MonoTouch.Foundation;
using MonoTouch.ObjCRuntime;
/**
* Copyright (c) 2014 Jon Lipsky
//
// ViewController.swift
// Tetris
//
// Created by Julius Parishy on 11/19/14.
// Copyright (c) 2014 Julius Parishy. All rights reserved.
//
import UIKit
class Client < Android::OS::AsyncTask
def doInBackground(params)
url = Java::Net::URL.new("http://www.bom.gov.au/fwo/IDN60901/IDN60901.94768.json")
reader = Java::IO::BufferedReader.new(Java::IO::InputStreamReader.new(url.openStream))
builder = Java::Lang::StringBuilder.new("")
while ((line = reader.readLine()) != nil) do
builder.append(line)
end
puts builder.toString
@pixlwave
pixlwave / core_ext.rb
Last active August 29, 2015 14:15
Swift style initializers for RubyMotion
class NSObject
def self.with(args = {})
args.count == 0 ? method = "init" : method = "initWith"
objc_args = []
args.each do |a|
a[0] = a[0][0].capitalize + a[0][1..-1] if objc_args.size < 1
method << a[0] << ":"
#!/usr/bin/env ruby
require 'rubygems'
require 'osx/cocoa'
app = OSX::NSApplication.sharedApplication
window = OSX::NSWindow.alloc.initWithContentRect_styleMask_backing_defer(
[0,0,500,500],
OSX::NSTitledWindowMask + OSX::NSClosableWindowMask,
@dbgrandi
dbgrandi / netservices_macruby.rb
Created November 9, 2009 11:15 — forked from voodootikigod/netservices_macruby.rb
Using the NSNetServiceBrowser with macruby
delegate = Object.new
def delegate.netServiceBrowserWillSearch(browser)
puts "search commencing!"
end
def delegate.netServiceBrowser(browser, didFindService:service, moreComing:more)
# this never calls regardless of the services on the network.
puts "Found service #{service.name}."
end