Skip to content

Instantly share code, notes, and snippets.

@mathiasverraes
mathiasverraes / with_stashes.sh
Last active June 23, 2018 14:12
Show git branch name on command prompt. Put this in your ~/.bash_profile or whatever your OS uses, then restart your terminal and cd to a git folder. It should look something like: yourname@machine /path/to/project [my-branchname] $ UPDATE: the `with_stashes.sh` version also shows the number of entries in your git stash on the command prompt. Sc…
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \[\1\]/'
}
# git branch on command prompt
if [[ ${EUID} == 0 ]] ; then
PS1='\[\033[01;31m\]\u@\h \[\033[01;34m\]\w\[\033[01;35m\]$(parse_git_branch)\[\033[01;34m\] \$ \[\033[00m\]'
else
PS1='\[\033[01;31m\]\u@\h \[\033[01;00m\]\w\[\033[00;33m\]$(parse_git_branch)\[\033[00m\] \$ '
fi
@nzakas
nzakas / gist:5511916
Created May 3, 2013 17:47
Using GitHub inside a company

I'm doing some research on how companies use GitHub Enterprise (or public GitHub) internally. If you can help out by answering a few questions, I'd greatly appreciate it.

  1. What is the primary setup? Is there an organization and each official repo is owned by that organization?
  2. Does every engineer have a fork of each repo they're working on?
  3. Are engineers allowed to push directly to the official repo? Or must all commits go through a pull request?
  4. Do engineers work on feature branches on the main repo or on their own forks?
  5. Do you require engineers to squash commits and rebase before merging?
  6. Overall, what is the workflow for getting a new commit into the main repository?
  7. What sort of hooks do you make use of?
  8. Are there any ops issues you encountered? (Scaling, unforeseen downtime, etc.)
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active May 7, 2024 01:27
A badass list of frontend development resources I collected over time.
@staltz
staltz / introrx.md
Last active May 20, 2024 14:59
The introduction to Reactive Programming you've been missing
@davidallsopp
davidallsopp / Shrinking.scala
Last active January 30, 2024 13:25
Solutions to the ScalaCheck problem that shrinking failing values may generate invalid values, because the constraints of the generator are not respected. This is for using ScalaCheck from within ScalaTest.
import org.scalatest._
import prop._
import org.scalacheck.Arbitrary._
import org.scalacheck.Gen
/**
* Solutions to the ScalaCheck problem that shrinking failing values may generate
* invalid values, because the constraints of the generator are not respected.
*
* See also http://stackoverflow.com/questions/20037900/scalacheck-wont-properly-report-the-failing-case
@mnot
mnot / snowden-ietf93.md
Last active September 12, 2023 13:40
Transcript of Edward Snowden's comments at IETF93.
@kiritsuku
kiritsuku / ClickStreamExample.scala
Last active September 24, 2018 00:44
click stream example
import java.awt.Dimension
import java.awt.event.MouseAdapter
import java.awt.event.MouseEvent
import javax.swing.JFrame
import scala.collection.immutable
import scala.concurrent.duration._
import akka.actor._
import akka.stream._
@kiritsuku
kiritsuku / ComplexTcpClient.scala
Last active August 15, 2018 06:11
Complex TCP server and client
import scala.io.StdIn
import scala.util._
import akka.actor._
import akka.stream._
import akka.stream.scaladsl._
import akka.stream.stage._
import akka.util._
object ComplexTcpClient extends App {

Explaining Miles's Magic

Miles Sabin recently opened a pull request fixing the infamous SI-2712. First off, this is remarkable and, if merged, will make everyone's life enormously easier. This is a bug that a lot of people hit often without even realizing it, and they just assume that either they did something wrong or the compiler is broken in some weird way. It is especially common for users of scalaz or cats.

But that's not what I wanted to write about. What I want to write about is the exact semantics of Miles's fix, because it does impose some very specific assumptions about the way that type constructors work, and understanding those assumptions is the key to getting the most of it his fix.

For starters, here is the sort of thing that SI-2712 affects:

def foo[F[_], A](fa: F[A]): String = fa.toString
@jkpl
jkpl / writing_tech_articles.md
Last active April 16, 2024 10:45
Writing tech articles

Writing tech articles

This is a description of how I write tech articles for various blogs. Hopefully someone else will find this useful as well.

Create a Gist for the article

When I begin writing a new article, I create a new [GitHub Gist][gist] for the article files. The Gist contains a file for the article text and code examples related to the article.