Skip to content

Instantly share code, notes, and snippets.

View baweaver's full-sized avatar
📝
Documenting things

Brandon Weaver baweaver

📝
Documenting things
View GitHub Profile
@KL-7
KL-7 / one-liners.md
Created January 10, 2012 19:49
Ruby one-liners

One-liners

Reverse every line:

Input file:

$ cat foo
qwe
123

bar

@helena
helena / TrySamples.scala
Last active July 13, 2021 15:03
Try introduced in Scala 2.10.0
// Start by adding these
import scala.util.{ Try, Success, Failure }
/**
* Sample runs code that raises the exception:
* java.lang.ArithmeticException: / by zero
*/
object Sample {
def main(args: Array[String]): Unit = {
@madlep
madlep / applicative.rb
Last active January 11, 2021 01:12
Ruby validation applicative example
class Either
def self.pure(value)
Right.new(value)
end
class Left
def initialize(left)
@left = left
end
@bitemyapp
bitemyapp / gist:ac316a6eb666695ff7d2
Last active November 4, 2020 04:11
How I talk about Haskell when I want people to care about learning Haskell

Fire up ghci. Make the text real big. Always show the types for everything as you go!

Takes ~1 hour generally.

Note: if you object to "uncertainty" (evocative of data/value flow possibilities), consider wording like "simultaneously possible values". It's a reference to how the compiler won't know whether Maybe a is a Just a or a Nothing statically. Don't blather at me about dependent types; I know.

Alternate verbiage for uncertainty: product - simultaneous altogetherness, sum - simultaneous singlehood. Also consider what the category theoretic diagrams look like. Can be instructive.

Suggestions taken under advisement.

@nu7hatch
nu7hatch / spec_helper.rb
Created October 17, 2010 21:46
Testing standard input with RSpec
...
module Helpers
# Replace standard input with faked one StringIO.
def fake_stdin(*args)
begin
$stdin = StringIO.new
$stdin.puts(args.shift) until args.empty?
$stdin.rewind
yield
Writing a billing system in Haskell, using Stripe and Heroku
===
*This post is written in literate Haskell, meaning the source can be turned
into a blogpost or a working program. You can view the [source][source].
[source]: https://gist.github.com/gatlin/7754289
Normally clients pay me with checks, but recently one informed me that they
really really really like *really really* super prefer some kind of online
@gbrayut
gbrayut / Systemd.service
Created December 8, 2015 18:14
Bosun Service files
#Bosun unit file at /etc/systemd/system/bosun.service
[Unit]
Description=Bosun Service
After=network.target
After=docker.service
After=rsyslog.service
[Service]
Type=simple
User=root
@velvia
velvia / spark-jobserver-ui-thoughts
Created July 29, 2016 07:45
Thoughts on requirements for SJS UI
* See all current contexts
* For each context see all the jobs that are running
* History of past jobs for a given context. Actually this is not technically available via API; but history of past jobs
* Be able to see configuration for each job present or past (this is available via a tiny "C" link in current UI)
* Job results
* Link to Spark UI for detailed analysis
@havenwood
havenwood / tco.patch
Created April 27, 2015 15:05
Patch to enable Tail Call Optimization in Ruby
diff --git a/vm_opts.h b/vm_opts.h
index b67e254..3e3935a 100644
--- a/vm_opts.h
+++ b/vm_opts.h
@@ -18,8 +18,8 @@
* Following definitions are default values.
*/
-#define OPT_TRACE_INSTRUCTION 1
-#define OPT_TAILCALL_OPTIMIZATION 0
var gulp = require( 'gulp' ),
server = require( 'gulp-develop-server' );
// run server
gulp.task( 'server:start', function() {
server.listen( { path: './app.js' } );
});
// restart server if app.js changed
gulp.task( 'server:restart', function() {