Skip to content

Instantly share code, notes, and snippets.

View softprops's full-sized avatar
®️
Rustling

Doug Tangren softprops

®️
Rustling
View GitHub Profile

Configuring SBT to use 1Password

  1. Install swig-python
  2. Use pip to install 1pass
  3. Install py-levenshtein to avoid annoying warnings
  4. Locate the nearest 1pass script (note: it may be behind you)
  5. Test 1pass on a random password

Create ~/.sbt/0.13/plugins/build.sbt with the following contents:

@hochgi
hochgi / InputStream2ReqBody.scala
Last active August 29, 2015 14:08
Dispath with custom data sources (example with InputStream)
import dispatch._ ,Defaults._
import com.ning.http.client.Request.EntityWriter
import org.apache.commons.compress.utils.IOUtils
import java.io.{InputStream, OutputStream}
implicit def InputStream2EntityWriter(in: InputStream): EntityWriter = new EntityWriter {
override def writeEntity(out: OutputStream): Unit = {
IOUtils.copy(in,out)
in.close
out.close
class Bippy(override val toString: String)
trait A { implicit def lowPriority: Bippy = new Bippy("A") }
object B extends A { implicit def highPriority: Bippy = new Bippy("B") }
object C { implicit def highPriority: Bippy = new Bippy("C") }
object Test {
def main(args: Array[String]): Unit = {
import B._, C._
println( implicitly[Bippy] ) // Prints: A
ubuntu@ip-10-74-149-134:~$ mkdir rust-buildbox
ubuntu@ip-10-74-149-134:~$ cd rust-buildbox/
ubuntu@ip-10-74-149-134:~/rust-buildbox$ vim Dockerfile
ubuntu@ip-10-74-149-134:~/rust-buildbox$ docker build -t rust-buildbox .
ubuntu@ip-10-74-149-134:~/rust-buildbox$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
rust-buildbox latest be231641cce2 18 seconds ago 1.277 GB
ubuntu 14.04 c4ff7513909d 11 days ago 213 MB
ubuntu@ip-10-74-149-134:~/rust-buildbox$ docker run -t -i rust-buildbox /bin/bash
root@45ac8578f983:/# cd /home/rust/
@macabreb0b
macabreb0b / meetupMassUnsubscribe
Last active October 24, 2022 21:18
Unsubscribe from all group notifications on Meetup.com
// Tired of getting Meetup.com notifications? Me too.
// 1. Navigate to: http://www.meetup.com/account/comm/ (you must be logged in!)
// 2. Open your browser's console, and paste in the script below:
$('.commSettings').each(function(idx, item) {var $item = $(item);var boardId = $item.attr("id").split('_')[1];var url = $item.children('form').attr('action');var params = {evRemind:1,mailing_list_status:0, submitButton:'Save Settings', submit:'submit'};params['board_' + boardId] = boardId;$.ajax({data: params, url: url, type: 'post'});});$('.generalEmailSettings').find('input[type="checkbox"]').prop('checked', false);$('.generalEmailSettings').find('input[type="submit"]').click();
@jsuereth
jsuereth / .create-travis-cache.sh
Last active December 7, 2015 14:55
Travis CI caching hackeries
#!/bin/bash
# very simple script to generate a tar of dependencies in ivy cache for extraction in TravisCI.
# usage: ./.create-travis-cache.sh <sbt-command>*
#
# By Default this will run `sbt update` with a clean cache directory and
# generate a .tar.bz2 with all the artifacts. This file can be pushed into
# dropbox and expanded in your TravisCI server later for a slight improvement
# in resolution times.
object Fλip {
val tParams = (1 to 23).map { i =>
(i + 'A' - 1).toChar
}
def getParams(arity: Int): IndexedSeq[Char] =
(0 to arity).map(tParams(_))
def getTypeSig(seq: IndexedSeq[Char]) =
s"""(${seq.init.mkString(",")}) => ${seq.last}"""
import scala.language.higherKinds
trait Bifunctor[BF[_, _]] {
def bimap[A, B, C, D](bf: BF[A, C], fab: A => B, fcd: C => D): BF[B, D]
/* Mapping over one of the sides is convenient and can be implemented easily
in terms of `bimap`. */
/** Map over the "first" side, transforming the type and potentially the value
(if the BF instance is of the "first" type, natrually.) */
<?php
/*
* This is a simple example of using PHP's OAuth extension to fetch a valid
* token for a given member. The process is a typical OAuth 1.0a flow, which
* includes requesting a member's authorization to act on her behalf and then
* fetching the actual token once authorized. This token can then be stored
* and used to make API calls on the member's behalf. For an example of making
* such a call once you have retriefed an authorized token, see:
*
@non
non / Doge.scala
Last active September 8, 2016 12:28
From an anonymously published paper I found online: the Doge monad (translated to Scala).
package shibe
object Doge {
def such[A](a: A): Doge[A] = Such(a)
def so[A](a1: A, a2: A): Doge[A] = So(a1, a2)
def wow[A]: Doge[A] = Wow()
def pure[A](a: A): Doge[A] = such(a) // added for stew on #scala
}