Skip to content

Instantly share code, notes, and snippets.

David Barri japgolly

Block or report user

Report or block japgolly

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@japgolly
japgolly / min.css
Created Oct 15, 2017
Sample ScalaCSS > 26
View min.css
._b0{color:#000}._b2{color:#c00}._b3 svg{max-width:100%}._b4{width:24px !important;text-align:center !important}._b5{padding-bottom:1rem;padding-top:0.5rem}._b6:first-child{margin-top:0 !important}._b6:not(:first-child){margin-top:1.8em !important}._b6{margin-bottom:0.2em !important;padding-top:0.8em !important;padding-bottom:0.3em !important}._b7{margin-top:0 !important}._b8{cursor:pointer}._b9{text-align:center;padding-top:2.7em !important;height:6.8em !important;-moz-flex-grow:0 !important;-webkit-flex-grow:0 !important;-ms-flex-grow:0 !important;-o-flex-grow:0 !important;flex-grow:0 !important}._ba{font-size:3rem !important}._bb{border-color:red !important}._bc{margin-bottom:1em}._bc tr:nth-child(odd) td._s{background-color:#fffde8}._bc tr:nth-child(even) td._s{background-color:#def2fc}._bc tr:nth-child(odd) td._d{background-color:#fcf8e3}._bc tr:nth-child(even) td._d{background-color:#d9edf7}._bd{font-family:monospace;background-color:#fff}._be{font-family:monospace;white-space:nowrap;color:#f39}._bf{t
View CallbackReusability.scala
import japgolly.scalajs.react._
import japgolly.scalajs.react.extra._
import japgolly.scalajs.react.vdom.html_<^._
object NotReusable {
final case class Props(name: String, update: Callback)
final class Backend($: BackendScope[Props, Unit]) {
def render(p: Props): VdomElement =
View blog-201706.scala
sealed trait Field {
type Value
def fold[F[_]](f: Field.Fold[F]): F[Value]
}
object Field {
case object Name extends Field {
override type Value = String
override def fold[F[_]](f: Field.Fold[F]): F[Value] = f.name(this)
}
@japgolly
japgolly / setup.sh
Last active Apr 27, 2017
NodeJS + Scala.JS
View setup.sh
npm config set prefix ~/.npm
npm install -g jsdom source-map-support yarn
export NODE_PATH="$(npm config get prefix)"/lib/node_modules
export PATH="$PATH:$(npm config get prefix)/bin"
View keybase.md

Keybase proof

I hereby claim:

  • I am japgolly on github.
  • I am japgolly (https://keybase.io/japgolly) on keybase.
  • I have a public key ASA2mh3TjdvZuvSBDifylawPHaTJDuBE4NQhXtZR8vhF4Ao

To claim this, I am signing this object:

View ReactCollapse.scala
import japgolly.scalajs.react._
import scalajs.js.{undefined, Dictionary, Dynamic, Object, UndefOr}
import shipreq.base.util.Memo
import ReactCollapse._
/**
* Component-wrapper for collapse animation with react-motion for elements with variable (and dynamic) height.
*
* https://github.com/nkbt/react-collapse
*/
View JsEnvUtils.scala
import scala.util.Try
import scalajs.js.Dynamic.global
object JsEnvUtils {
/** Sample (real) values are:
* - Mozilla/5.0 (Unknown; Linux x86_64) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1
* - Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0
* - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.75 Safari/537.36
*/
@japgolly
japgolly / InBrowserTesting.scala
Last active Nov 18, 2016
SBT + Scala.JS + Selenium
View InBrowserTesting.scala
import sbt._
import sbt.Keys._
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
import org.scalajs.sbtplugin.cross.CrossProject
import org.scalajs.sbtplugin.ScalaJSPluginInternal._
import org.scalajs.jsenv.selenium._
object InBrowserTesting {
lazy val testAll = TaskKey[Unit]("test-all", "Run tests in all test platforms.")
View inter.hs
{-# LANGUAGE TypeOperators #-}
module Main where
import Data.Bifunctor (first)
type (~>?) s a = (Either a s) -> (Either s a)
data Inter s a = Inter { getE :: s ~>? a
, reverseGetE :: a ~>? s }
composeS :: (a ~>? b) -> (b ~>? c) -> (a ~>? c)
@japgolly
japgolly / AutoCompleteFeature.scala
Created Feb 3, 2016
scalajs-react + AutoComplete
View AutoCompleteFeature.scala
package shipreq.webapp.client.feature
import japgolly.scalajs.react._
import japgolly.scalajs.react.extra._
import org.scalajs.dom.html
import scala.scalajs.js
import shipreq.base.util.ScalaExt.EndoFn
import shipreq.base.util.Vector1
import shipreq.webapp.client.jsfacade.TextComplete
import shipreq.webapp.client.lib.TextEditor
You can’t perform that action at this time.