Skip to content

Instantly share code, notes, and snippets.

View goseign's full-sized avatar

Xu Bin goseign

  • Home
  • Mountain view, CA
View GitHub Profile
@goseign
goseign / 46f00aff2ed_2.scala
Created August 24, 2018 17:45 — forked from phantomastray/46f00aff2ed_2.scala
46f00aff2ed word search problem
case class GridCell(x: Int, y: Int)
def exist(board: Array[Array[Char]], word: String): Boolean = {
val deltaVector = List((0, -1), (0, 1), (1, 0), (-1, 0))
def inBounds(cell: GridCell) = cell.x >= 0 && cell.x < board.length && cell.y >= 0 && cell.y < board(0).length
def dfs(word: List[Char], currentCell: GridCell, visited: List[GridCell]): Boolean = {
word match {
@goseign
goseign / FindNonexistentFile.scala
Created August 22, 2018 23:53 — forked from halfninja/FindNonexistentFile.scala
Useful Scala snippets
def newTempFile() = new File(IoTmpDir, "JavaTestTmp-"+random.nextLong())
/*
* Tries 10 times to find a nonexistent file.
* Uses Streams to lazily go through a range, generating a fresh
* file each time.
*/
val dir = Stream.range(1,10)
.map { newTempFile() }
.find(!_.exists)

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@goseign
goseign / layout.scala
Created June 21, 2018 18:15 — forked from rjurney/layout.scala
Disappearing labels when I run the fix to make the Label Adjust overlap work
import java.awt.Color
import java.io.File
import java.io.IOException
import org.gephi.data.attributes.api.AttributeColumn
import org.gephi.data.attributes.api.AttributeController
import org.gephi.data.attributes.api.AttributeModel
import org.gephi.filters.api.FilterController
import org.gephi.filters.api.Query
import org.gephi.filters.api.Range
import org.gephi.filters.plugin.graph.DegreeRangeBuilder.DegreeRangeFilter
@goseign
goseign / simple-promise-retry.js
Created June 5, 2018 20:13 — forked from briancavalier/simple-promise-retry.js
A few general patterns for retries using promises
function keepTrying(otherArgs, promise) {
promise = promise||new Promise();
// try doing the important thing
if(success) {
promise.resolve(result);
} else {
setTimeout(function() {
keepTrying(otherArgs, promise);
@goseign
goseign / 0_reuse_code.js
Last active August 29, 2015 14:23
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console