Skip to content

Instantly share code, notes, and snippets.

@mguillermin
mguillermin / generated_jsRoutes.js
Last active May 24, 2016 21:57
Submitting Ajax POST with PlayFramework 2.x and the Javascript Router
...
_nS('controllers.admin.Products'); _root.controllers.admin.Products.search =
function() {
return _wA({method:"POST", url:"/" + "admin/product/search"})
}
...
@(field:Field, min:Int=1)(f: (Field, Int) => Html)
@{
(0 until math.max(if (field.indexes.isEmpty) 0 else field.indexes.max + 1, min)).map(i => f(field("[" + i + "]"),i))
}
Datomic.q(Query(
s"""[:find ?name
:in $$
:where [_ :db/ident ?ident]
[(namespace ?ident) ?ns]
[(name ?ident) ?name]
[(= ?ns "namespace_name")]
]"""
), database).foreach {
case name: String => println(name)
@tanitanin
tanitanin / optionBinder.scala
Last active July 27, 2018 18:58
QueryStringBindable and Formatter for Option[T] ( @ Play Framework 2.x )
import play.api.data._
import play.api.data.format._
import play.api.data.format.Formats._
/**
* Option[T]をクエリとして解決するためのバインダ(必須でないパラメータなどに利用することを想定)
* 通常のFormと同様にbindFromRequestして使う
* クエリに該当するキーが含まれていない場合にはFormの値がNoneになる
*
* こんなかんじ (もっときれいに書きたいけど):
@nickdandakis
nickdandakis / package.json
Last active April 11, 2019 10:44
Next.js + AWS Elastic Beanstalk + AWS EC2 Container Service + Docker package.json
{
"name": "this-web-scale",
"version": "0.0.1",
"scripts": {
"dev": "node server.js",
"build": "NODE_ENV=production next build",
"start": "NODE_ENV=production node server.js",
"dockerize": "npm run build:docker && npm run tag:docker && npm run push:docker && npm run tag-latest:docker && npm run push-latest:docker",
"deploy": "eb use this-web-scale-production && eb deploy --label v$npm_package_version --verbose",
"build:docker": "docker build -t $npm_package_config_docker_image:$npm_package_version -t $npm_package_config_docker_image:latest .",
@ryanttb
ryanttb / install_node_lsw.sh
Last active December 4, 2019 14:28
Install node on Linux Subsystem for Windows
#!/bin/sh
# this script requires root
# be sure to run the following before running this:
# $ sudo su
# since there's an issue piping the curl response to bash
# just download the install script
curl -sL https://deb.nodesource.com/setup_6.x > install_node.sh
@nyango
nyango / WildcardAllowedCORSFilterFactory.scala
Last active December 24, 2019 06:37
Play CORS Filter with wildcard origin matching
import javax.inject.{Inject, Singleton}
import akka.stream.Materializer
import play.api.Configuration
import play.filters.cors.CORSConfig.Origins.Matching
import play.filters.cors.{CORSConfig, CORSFilter}
import scala.concurrent.ExecutionContext
import scala.util.matching.Regex
@magicspon
magicspon / server.js
Created November 7, 2018 09:48
using https with next
const https = require('https')
const { parse } = require('url')
const next = require('next')
const fs = require('fs')
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
const options = {
package ws.eiennohito.utils.serialization
import java.lang.reflect.Modifier
import java.util.concurrent.ConcurrentHashMap
import akka.serialization.Serializer
import com.google.protobuf.CodedOutputStream
import com.trueaccord.scalapb.{GeneratedMessage, GeneratedMessageCompanion}
import com.typesafe.scalalogging.StrictLogging