Skip to content

Instantly share code, notes, and snippets.

View hhariri's full-sized avatar

Hadi Hariri hhariri

View GitHub Profile
@hhariri
hhariri / conneg.kt
Last active December 20, 2015 19:39
server.conneg() {
onAcceptHeader()
onExtension()
onQueryParameter("format")
}
server.get("/customer/:id",
{
@hhariri
hhariri / favicon.kt
Last active December 20, 2015 18:29
// implementation of favicon interceptor
public class FavIconInterceptor(val icon: String): Interceptor {
override fun intercept(request: Request, response: Response): Boolean {
if (request.method == HttpMethod.GET && request.uri.compareToIgnoreCase("/favicon.ico") == 0) {
response.streamFile(icon, "image/x-icon")
return true
}
return false
var appServer = AppServer()
server.static('/public')
server.start()
fun takeExtension(func: (Customer.() -> Unit)) {
}
fun takeAFunc(func: (String) -> Unit) {
}
fun theFunc(input: String) {
fun takeAFunc(func: (String) -> Unit) {
}
fun theFunc(input: String) {
}
fun useAFunc() {
val server = AppServer()
server.conneg() {
onAcceptHeader()
onExtension()
onQueryParameter("format")
}
server.intercept(BasicAuthenticationInterceptor("secure area", { (user: String, pass: String) -> user == pass}), "*")
server.get("/customer/:id",
server.conneg() {
onAcceptHeader()
onExtension()
onQueryParameter("format")
}
server.get("/customer/:id",
any {
},
"text/html" to {
// return a web page
},
"application/json" to {
// return json
}
app.directive('projectLocator', function () {
return {
restrict: 'E',
scope: {
},
templateUrl: '/partials/projectLocator.html',
controller: function ($scope, $resource) {
$scope.selectd = undefined;
$scope.message = 'loading projects...';
$resource('/teamcity/projects').query(function (result) {
Son we live in a world that has JavaScript, needs JavaScript.
And while my existence might seem grotesque, somebody needs to
write and maintain this JavaScript. We use words such as closures
and functions with honour, with understanding. You use them to mock
JavaScript and what we do at your user groups. So instead
of using that web site to register for your little trips and then question
the same technology that runs it, I'd rather you just say thank you
and go on your way. Either way, I don't give a crap what you think about JavaScript.