Skip to content

Instantly share code, notes, and snippets.

@FlicAnderson
FlicAnderson / howTo_BFGrepo.sh
Created November 20, 2014 16:49
How to run BFG to slim large repos
# How to run BFG to slim large repos: howToBFGrepo.sh
# ====================================================
# (20th November 2014)
# Author: Flic Anderson
# Written using Git Bash v1.9.2; Windows 7; BFG Repo-Cleaner 1.11.8
# ~ standalone script to use in bash
# AIM: To remove stupidly large files from a repo that you've had in there for some time,
# .... figure out whether they are all over a certain size (eg. 500K) and that they are ALL deletable.
# .... delete what you can, and commit each deletion so it's recorded.
@gabrielemariotti
gabrielemariotti / Readme.md
Last active March 2, 2024 23:10
A SimpleSectionedRecyclerViewAdapter: use this class to realize a simple sectioned `RecyclerView.Adapter`.

You can use this class to realize a simple sectioned RecyclerView.Adapter without changing your code.

The RecyclerView should use a LinearLayoutManager. You can use this code also with the TwoWayView with the ListLayoutManager (https://github.com/lucasr/twoway-view)

This is a porting of the class SimpleSectionedListAdapter provided by Google

Screen

Example:

@dk8996
dk8996 / HTTPSRedirectFilter.scala
Last active June 25, 2017 20:53
Play Framework Filter for AWS Elastic Load Balancer (forward HTTP to HTTPS)
import com.typesafe.scalalogging.slf4j.Logging
import play.api.mvc._
import scala.concurrent.Future
import play.mvc.Results._
import play.api.libs.concurrent.Execution.Implicits.defaultContext
object HTTPSRedirectFilter extends Filter with Logging {
def apply(nextFilter: (RequestHeader) => Future[SimpleResult])(requestHeader: RequestHeader): Future[SimpleResult] = {
//play uses lower case headers.
@viktorklang
viktorklang / Future-retry.scala
Last active July 23, 2023 23:48
Asynchronous retry for Future in Scala
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import akka.pattern.after
import akka.actor.Scheduler
/**
* Given an operation that produces a T, returns a Future containing the result of T, unless an exception is thrown,
* in which case the operation will be retried after _delay_ time, if there are more possible retries, which is configured through
* the _retries_ parameter. If the operation does not succeed and there is no retries left, the resulting Future will contain the last failure.
@jroper
jroper / MyManagedResource.scala
Last active November 4, 2021 10:20
Play resource routing
class MyManagedResource extends ResourceController[String] {
def index = Action(Ok("index"))
def newScreen = Action(Ok("new"))
def create = Action {
Redirect(MyInjectableResource.reverseRoutes.index())
}
def show(id: String) = Action(Ok("Show " + id))
@bartschuller
bartschuller / build.sbt
Last active May 17, 2018 19:28
Using Scala's Dynamic trait and reflection to implement delegation. If we swap reflection for macros it will be fast and typesafe again. I guess this could then replace the AutoProxy compiler plugin.
name := "delegation"
scalaVersion := "2.10.0"
libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-reflect" % _)
@julienrf
julienrf / Application.scala
Created April 26, 2012 20:47
Write a Mapping[A] and get a QueryStringBindable[A] for free
// --- Definition of a query string binder for type A using a Mapping[A]
object Binders {
implicit def mappingBinder[A](implicit mapping: Mapping[A]) = new QueryStringBindable[A] {
override def bind(key: String, params: Map[String, Seq[String]]): Option[Either[String, A]] = {
val data = for {
(k, ps) <- params
if k startsWith key
p <- ps.headOption
} yield (k.drop(key.length + 1), p)
@daithiocrualaoich
daithiocrualaoich / gist:1189097
Created September 2, 2011 16:37
Scala Collections Pimp to add distinctBy(hash: ... => ...) for hash filterings
implicit def seq2Distinct[T, C[T] <: Seq[T]](tees: C[T]) = new {
import collection.generic.CanBuildFrom
import collection.mutable.{HashSet => MutableHashSet}
def distinctBy[S](hash: T => S)(implicit cbf: CanBuildFrom[C[T],T,C[T]]): C[T] = {
val builder = cbf()
val seen = MutableHashSet[S]()
for (t <- tees) {
if (!seen(hash(t))) {
@technoweenie
technoweenie / github_oauth_busy_developer_guide.md
Created May 30, 2010 18:34
GitHub OAuth Busy Developer's Guide

GitHub OAuth Busy Developer's Guide

This is a quick guide to OAuth2 support in GitHub for developers. This is still experimental and could change at any moment. This Gist will serve as a living document until it becomes finalized at Develop.GitHub.com.

OAuth2 is a protocol that lets external apps request authorization to private details in your GitHub account without getting your password. All developers need to register their application before getting started.

Web Application Flow

  • Redirect to this link to request GitHub access:
# Video: http://rubyhoedown2008.confreaks.com/08-chris-wanstrath-keynote.html
Hi everyone, I'm Chris Wanstrath.
When Jeremy asked me to come talk, I said yes. Hell yes. Immediately. But
then I took a few moments and thought, Wait, why? Why me? What am I supposed
to say that's interesting? Something about Ruby, perhaps. Maybe the
future of it. The future of something, at least. That sounds
keynote-y.