Skip to content

Instantly share code, notes, and snippets.

View osaut's full-sized avatar

Olivier Saut osaut

View GitHub Profile
@skreutzberger
skreutzberger / randomColor.swift
Created August 12, 2015 14:38
generate random color in Swift
// returns a random color
func randomColor() -> UIColor{
let red = CGFloat(drand48())
let green = CGFloat(drand48())
let blue = CGFloat(drand48())
return UIColor(red: red, green: green, blue: blue, alpha: 1.0)
}
@kristopherjohnson
kristopherjohnson / pipe-forward.swift
Last active March 29, 2024 19:44
Swift: define F#-style pipe-forward (|>) operator that evaluates from left to right.
// F#'s "pipe-forward" |> operator
//
// Also "Optional-chaining" operators |>! and |>&
//
// And adapters for standard library map/filter/sorted
infix operator |> { precedence 50 associativity left }
infix operator |>! { precedence 50 associativity left }
infix operator |>& { precedence 50 associativity left }
infix operator |>* { precedence 50 associativity left }
@ttscoff
ttscoff / barchart.rb
Last active January 2, 2022 10:40
Command line bar chart from JSON data (for GeekTool, et al)
#!/usr/bin/env ruby
# encoding: utf-8
# Brett Terpstra 2013, WTF license <http://www.wtfpl.net/txt/copying/>
# Outputs a vertical bar chart from date-based JSON data
# Requires the JSON rubygem: `[sudo] gem install json`
require 'date'
require 'open-uri'
require 'rubygems'
require 'json'
pub trait RangedNum<T>: Num {
pub fn min() -> Self;
pub fn max() -> Self;
pub fn new(x: T) -> Self;
pub fn set(&mut self, x: T);
pub fn get(&self) -> T;
pub fn normalize(&self) -> Self;
pub fn normalize_self(&mut self);
}
@jmpinit
jmpinit / libload.sh
Last active June 6, 2020 15:28
How to use a shared library written in C from a program written in Rust. ( rust version 0.7. \ host: i686-unknown-linux-gnu ).
# so the lib can be found when the test is run
export LD_LIBRARY_PATH=./:$LD_LIBRARY_PATH
# alternatively put the .so generated after running make someplace where the system will find it
@gfontenot
gfontenot / Create OF Tasks.applescript
Created October 12, 2011 16:38
Send selected lines in BBEdit to OmniFocus
tell application "BBEdit"
set _sel to the selection
set _lines to lines in selection
set tasks_added to {}
repeat with _line in _lines
if length of _line is not 0 then
my makeOFTask(_line as text)
set end of tasks_added to _line as text
end if
end repeat