This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import scalaz.{Coproduct, Inject} | |
| trait X { self ⇒ | |
| type O[Z] | |
| def :+:(that: X): X { type O[Z] = Coproduct[that.O, self.O, Z] } = | |
| new X { type O[Z] = Coproduct[that.O, self.O, Z] } | |
| } | |
| object X { | |
| def apply[F[_]]: X { type O[Z] = F[Z] } = | |
| new X { type O[Z] = F[Z] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;;; Solarized configuration is a total clusterfuck, but on the other hand | |
| ;;; I've somehow got the bastard playing nicely with NS frames, TTY frames, | |
| ;;; and both NS /and/ TTY clients of both. | |
| ;;; | |
| ;;; - solarized-broken-srgb is always false as we're using the new sRGB in master. | |
| ;;; - solarized-assume-solarized-terminal is also set to t. This is a new customisation | |
| ;;; variable I introduced that tells Solarized to use the window system RGB codes for | |
| ;;; terminal faces, assuming that they'll be mapped to the correct Solarized colours. | |
| ;;; This should be trivial to hack into solarized-color-definitions, when index is set change | |
| ;;; (cond window-system ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| # First up, this is the bible: | |
| # https://stackoverflow.com/questions/6162484/why-does-modern-perl-avoid-utf-8-by-default | |
| # Also good | |
| # man perluniintro | |
| # man perlunitut | |
| # man perlunicode | |
| # Tested via `PERL_UNICODE=S perl test.pl < macron.txt` where macron.txt just contained |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| trait A | |
| trait B | |
| trait E | |
| trait S { | |
| def publish(e: E): Unit | |
| } | |
| object Foo { | |
| def p[F[+_]](f: F[E])(implicit F: Functor[F], s: S): F[Unit] = f.map(s.publish) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "wtf" in { | |
| trait Consumer { def consume(value: Root): Unit } | |
| sealed trait Root | |
| case class Alpha(s: String) extends Root | |
| case class Beta(s: String) extends Root | |
| val consumer = mock[Consumer] | |
| consumer.consume(Alpha("ss")) | |
| consumer.consume(Beta("ss")) | |
| there was two(consumer).consume(any[Alpha]) // I would expect this to fail but it doesn't. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun demangle () | |
| (interactive) | |
| (let* ((sym (thing-at-point 'symbol))) | |
| (with-temp-buffer | |
| (call-process "c++filt" nil t nil sym) | |
| (backward-delete-char 1) | |
| (message (buffer-string))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class foo { foo(); int x; }; | |
| foo::foo() try : x(1) { | |
| } catch (int e) { | |
| --x; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // init guaranteed to be non-empty | |
| // Basically this is trying to take a paginated response of Ts and turn it into a non-paginated list of all the Ts. | |
| val init: M[List[T]] // guaranteed to be non-empty | |
| val last: List[T] => T // does what it says on the tin | |
| val continue: T => Option[S] // given a response T, returns the key necessary to retrieve the next page | |
| val next: S => M[T] // given a key, retrieves the next page | |
| ... | |
| combine: (List[T], M[T]) => M[List[T]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (require 'cl) | |
| (require 'xml) | |
| (defun jabber-body-printer-with-xml (xml-data who mode) | |
| "Prints XMPP message bodies, linkifying <a> elements. | |
| See `jabber-chat-normal-body'. Requires Emacs 24.1 with LibXML2 support." | |
| (if (eq mode :insert) | |
| (let ((beginning (point))) | |
| (jabber-chat-normal-body xml-data who mode) | |
| (save-restriction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; Lets you insert a lambda using C-' l | |
| ;; Got the idea from Tim Bray, hence the name. Would be better as a minor mode or | |
| ;; something but I'm lazy and this works. | |
| (defun braysian-insert (c) | |
| "Inserts a special character." | |
| (interactive "c") | |
| (let* ((braysian-insertion-map '((?z . #x200b) ; zero width space | |
| (?S . #x2018) ; left single quote | |
| (?s . #x2019) ; right single quote | |
| (?' . #x2019) |