We have moved: https://github.com/magnetikonline/linuxmicrosoftievirtualmachines
Due to the popularity of this Gist, and the work in keeping it updated via a Gist, all future updates will take place at the above location. Thanks!
trait Enum { //DIY enum type | |
import java.util.concurrent.atomic.AtomicReference //Concurrency paranoia | |
type EnumVal <: Value //This is a type that needs to be found in the implementing class | |
private val _values = new AtomicReference(Vector[EnumVal]()) //Stores our enum values | |
//Adds an EnumVal to our storage, uses CCAS to make sure it's thread safe, returns the ordinal | |
private final def addEnumVal(newVal: EnumVal): Int = { import _values.{get, compareAndSet => CAS} | |
val oldVec = get |
def Secured[A](username: String, password: String)(action: Action[A]) = Action(action.parser) { request => | |
request.headers.get("Authorization").flatMap { authorization => | |
authorization.split(" ").drop(1).headOption.filter { encoded => | |
new String(org.apache.commons.codec.binary.Base64.decodeBase64(encoded.getBytes)).split(":").toList match { | |
case u :: p :: Nil if u == username && password == p => true | |
case _ => false | |
} | |
}.map(_ => action(request)) | |
}.getOrElse { | |
Unauthorized.withHeaders("WWW-Authenticate" -> """Basic realm="Secured"""") |
web: target/start -Dhttp.port=${PORT} -Dconfig.resource=prod.conf ${JAVA_OPTS} |
#!/bin/bash | |
# License: Public Domain. | |
# Author: Joseph Wecker, 2012 | |
# | |
# -- DEPRICATED -- | |
# This gist is slow and is missing .bashrc_once | |
# Use the one in the repo instead! https://github.com/josephwecker/bashrc_dispatch | |
# (Thanks gioele) | |
# | |
# Are you tired of trying to remember what .bashrc does vs .bash_profile vs .profile? |
def is_holiday(d): | |
"""Check whether the given dateutil.date is a Finnish national holiday""" | |
import dateutil.easter | |
from datetime import date, timedelta as td | |
assert isinstance(d, date) | |
md = '{}.{}'.format(d.day, d.month) | |
y = d.year | |
# Fixed-date holidays | |
if md in '1.1 6.1 1.5 6.12 24.12 25.12 26.12'.split(): return True | |
# Finnish midsummer (eve on Fri the 19..25th, day on Sat the 20..26th) |
object ProductionCached { | |
def apply[A](key: String, duration: Int)(action: Action[A]): Action[A] = { | |
if (play.Play.isTest || play.Play.isDev) | |
action | |
else | |
Cached(_ => key, duration)(action) | |
} | |
} |
// Public domain. | |
// Attribution welcome, but not required. -- Pyry Jahkola. | |
// What's the point in all this? To get the equivalent of CoffeeScript's | |
// (?.) operator into vanilla JavaScript. | |
// get(x, key1, key2, ...) -- Get the result of x[key1][key2]..., or undefined. | |
// Will short circuit if a key is not found. |
We have moved: https://github.com/magnetikonline/linuxmicrosoftievirtualmachines
Due to the popularity of this Gist, and the work in keeping it updated via a Gist, all future updates will take place at the above location. Thanks!
This is one way to pass some data (API tokens, etc.) to your Jekyll templates without putting it in your _config.yml
file (which is likely to be committed in your GitHub repository).
Copy the environment_variables.rb
plugin to your _plugins
folder, and add any environment variable you wish to have available on the site.config
object.
In a Liquid template, that information will be available through the site
object. For example, _layouts/default.html
could contain:
/* Flatten das boostrap */ | |
.well, .navbar-inner, .popover, .btn, .tooltip, input, select, textarea, pre, .progress, .modal, .add-on, .alert, .table-bordered, .nav>.active>a, .dropdown-menu, .tooltip-inner, .badge, .label, .img-polaroid { | |
-moz-box-shadow: none !important; | |
-webkit-box-shadow: none !important; | |
box-shadow: none !important; | |
-webkit-border-radius: 0px !important; | |
-moz-border-radius: 0px !important; | |
border-radius: 0px !important; | |
border-collapse: collapse !important; | |
background-image: none !important; |