Skip to content

Instantly share code, notes, and snippets.

require "orbit"
require "orbit.routes"
local R = orbit.routes.R
local hello = orbit.new()
hello:dispatch_get(function (web)
return string.format('<h1>Welcome to %s!</h1>', web.real_path)
@marciol
marciol / Hello.fs
Created May 7, 2012 00:35 — forked from mythz/Hello.fs
Stand-alone Hello World ServiceStack Web Service with F# on Mono/OSX hosted by HttpListener
(* Stand-alone Hello World ServiceStack Web Service with F# on Mono/OSX hosted by HttpListener
Instructions:
1) download https://github.com/ServiceStack/ServiceStack/downloads
2) fsharpc -r:ServiceStack.Common.dll -r:ServiceStack.Interfaces.dll -r:ServiceStack.Text.dll -r:ServiceStack.dll Hello.fs
3) sudo mono Hello.exe
Read More: For the benefits of a ServiceStack Hello World Service see: http://www.servicestack.net/ServiceStack.Hello/
*)
@marciol
marciol / FsVersion.fs
Created May 17, 2012 17:05 — forked from rojepp/FsVersion.fs
F# Translation for Miguel. I have no idea if this works, and it is pretty much a verbatim translation, only some F# flare added. I didn't dare to do too much refactoring without having a way to test properly. Original: https://github.com/xamarin/monotouch
namespace GLCameraRipple
open System
open System.Drawing
open System.Runtime.InteropServices
//open MonoTouch.CoreFoundation
open Microsoft.FSharp.NativeInterop
type RippleModel(screenSize : Size, meshFactor: int, touchRadius: int, textureSize: Size) =
do Console.WriteLine ("New RippleModel");
let poolWidth = screenSize.Width / meshFactor
@marciol
marciol / without_callback.rb
Created June 13, 2012 15:21
Simple WithOut Callbacks monkey patch for Active::Support::Callbacks::ClassMethods inspired from http://jeffkreeftmeijer.com/2010/disabling-activemodel-callbacks/
module ActiveSupport::Callbacks::ClassMethods
def without_callback(*args, &block)
skip_callback(*args)
result = yield
set_callback(*args)
return result
end
end
@marciol
marciol / mysqldump_tips
Created July 12, 2012 15:44
msyqldump command tips
# Only insert data
mysqldump --compact --no-create-info
# Only structure
mysqldump --compact --no-data
let newtonSqrt x =
let accuracy = 0.00001 // desired accuracy
let rec iterate a =
let diff = x - a*a
if abs diff <= accuracy
then a
else iterate ((a + x/a) / 2.0)
iterate (x/2.0)
val newtonSqrt : float -> float
let badcode x y =
if y
then newtonSqrt x
else newtonSqrt "abc"
let newtonSqrt (x : float) : float =
let accuracy : float = 0.00001 // desired accuracy
let rec iterate (x : float) (a : float) : float =
let diff : float = x - a*a
if abs diff <= accuracy
then a
else iterate x ((a + x/a) / 2.0)
iterate x (x/2.0)
@marciol
marciol / gist:3290143
Created August 7, 2012 22:43
Custom System Routes (Nancy inspired)
Get("foo/bar.html",
(request, response) => {
using (var connection = new SqlConnection(
System.Configuration.ConfigurationManager.AppSettings["strConnection"]))
{
connection.Open();
var result = connection.Query<ExecutiveReportResult>(
Util.getSql("rm_consulta_relatorio_executivo"),