Skip to content

Instantly share code, notes, and snippets.

@sergejmueller
sergejmueller / ttf2woff2.md
Last active March 9, 2024 13:37
WOFF 2.0 – Learn more about the next generation Web Font Format and convert TTF to WOFF2
var cat = function(obj){
//this is where I copy all the attributes of the passed object to the constructure
for (attr in obj){
this[attr] = obj[attr];
}
//publice method
this.talk = function(){
console.log('meeow!!!');
};
};
@timothyklim
timothyklim / Application.scala
Created June 12, 2012 17:22
After I talked with co-author of play with topic subdomains, I was a little bit confused. My current framework doesn't support my thoughts and I was started write some code!
// app/controllers/Application.scala
trait SubdomainController extends Controller {
def WithSubdomain(f: => String => Request[AnyContent] => Result) = Action { implicit request =>
val splitDomain = request.domain.split("\\.")
if (splitDomain.length < 2) {
BadRequest("Domain not found!")
} else {
f(splitDomain.head)(request)
@sundorf
sundorf / Mongo.scala
Created March 14, 2012 19:20
Play 2.0 Utility-Trait for Casbah/MongoDB
package models
import scala.Option.option2Iterable
import org.scalastuff.scalabeans.Preamble.descriptorOf
import org.scalastuff.scalabeans.BeanDescriptor
import com.mongodb.casbah.Imports._
import play.Logger
/**
* Utility trait for MongoDB to mix into entity classes.
@martinsik
martinsik / chat-frontend.js
Last active December 19, 2023 10:23
Node.js chat frontend and server
$(function () {
"use strict";
// for better performance - to avoid searching in DOM
var content = $('#content');
var input = $('#input');
var status = $('#status');
// my color assigned by the server
var myColor = false;
@kevinwright
kevinwright / PimpMyFilter.scala
Created October 4, 2011 22:11
Pimpin' + on a T => Either[ERR,T] for easy chaining
class Filters[T] {
//Some boilerplate-busting aliases
type FilterResult = Either[Rejection, T]
type FilterFunc = (T) => FilterResult
//Handy helpers
//Rejection can carry as much info as you wish;
// Filter name, value in error, an exception, etc.
case class Rejection(input: T, msg: String)