Skip to content

Instantly share code, notes, and snippets.

View danieldietrich's full-sized avatar

Daniel Dietrich danieldietrich

View GitHub Profile
@ZeroDragon
ZeroDragon / How to clone a git repo to an existing folder (not empty).md
Last active January 20, 2025 16:26
How to clone a git repo to an existing folder (not empty)
  1. First get to the existing directory
    $ cd my/folder/

  2. Now start a new git repository
    $ git init

  3. Identify if the current elements on the directory are needed or not and add them to the .gitignore file. When ready...
    $ vim .gitignore

  4. When ready create the first commit on the server

@luciferous
luciferous / codensity-tree.scala
Created April 2, 2013 21:36
Codensity of Trees
sealed trait TreeLike[M[_]] {
def node[A](f: M[A], g: M[A]): M[A]
}
sealed trait Tree[+A] { self =>
def flatMap[B](f: A => Tree[B]): Tree[B] = self match {
case Leaf(a) => f(a)
case Node(l, r) => Node(l.flatMap(f), r.flatMap(f))
}
}
@leon
leon / Detail.java
Created February 8, 2013 06:25
Play-Scalr Image Ebean Entity
package models;
import java.util.*;
import javax.persistence.*;
import com.avaje.ebean.Expr;
import com.avaje.ebean.Query;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import play.data.validation.Constraints;
@cobyism
cobyism / gh-pages-deploy.md
Last active November 8, 2025 17:19
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@sadache
sadache / gist:4714280
Last active July 14, 2022 15:09
Playframework: Async, Reactive, Threads, Futures, ExecutionContexts

Asynchronicity is the price to pay, you better know what you're paying for...

Let's share some vocabulary first:

Thread: The primitive responsible of executing code on the processor, you can give an existing (or a new) Thread some code, and it will execute it. Normally you can have a few hundreds on a JVM, arguments that you can tweak your way out to thousands. Worth noting that multitasking is achieved when using multiple Threads. Multiple Threads can exist for a single processor in which case multitasking happens when this processor switches between threads, called context switching, which will give the impression of things happenning in parallel. An example of a direct, and probably naive, use of a new Thread in Java:

public class MyRunnable implements Runnable {
  public void run(){
 System.out.println("MyRunnable running");
@asflierl
asflierl / scala_2.10_
Created January 30, 2013 19:44
Dependent method types in Scala 2.10.... ooooOOOO yeah!
Welcome to Scala version 2.10.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_11).
Type in expressions to have them evaluated.
Type :help for more information.
scala> trait Meep { type Moop; def f: Moop }
defined trait Meep
scala> def fnord(a: Meep): a.Moop = a.f
fnord: (a: Meep)a.Moop
@bigtoast
bigtoast / Shell
Last active December 11, 2015 23:18
# to install the latest stable version:
brew install play
# to install play-2.1-RC3:
# if you already have a version of play installed you will need to unlink it.
brew unlink play
brew install https://raw.github.com/gist/4675514/play.rb
# to switch versions (from https://github.com/mxcl/homebrew/wiki/External-Commands):
brew switch play 2.0.4
@paulp
paulp / The Signs of Soundness
Last active June 17, 2021 06:48
The Signs of Soundness
Hello scala, my old friend
I've come to take you home again
Because a feature slowly creeping
left me plagued with doubts and weeping
and the version that was tagged in the repo
just has to go
it lacks the signs of soundness
On sleepless nights I hacked alone
applying ant and other tools of stone
@rjgx4
rjgx4 / Shell
Last active December 10, 2015 20:08
# to install the latest stable version:
brew install play
# to install play-2.1-RC2:
brew install https://raw.github.com/gist/4485598/play.rb
# to switch versions (from https://github.com/mxcl/homebrew/wiki/External-Commands):
brew switch play 2.0.4
brew switch play 2.1-RC2
@tonymorris
tonymorris / FList.scala
Last active December 10, 2015 02:18
foldMap is equivalent to scala.List
trait Semigroup[A] {
def op(a1: A, a2: A): A
}
trait Monoid[A] extends Semigroup[A] {
def id: A
}
object Monoid {
implicit def ListMonoid[A]: Monoid[List[A]] =