Skip to content

Instantly share code, notes, and snippets.

View odadoda's full-sized avatar

Øyvind Dahl odadoda

View GitHub Profile
@odadoda
odadoda / if.sh
Last active January 9, 2018 12:43
Bash if
if [ test-commands ]; then
#do something
elif [ more-commands ]; then
#do more something]
else
#do something else
fi
@odadoda
odadoda / docker-compose.yml
Created September 29, 2017 14:05
Wordpress and mariadb docker compose
version: "3.1"
services:
wordpress:
image: wordpress
ports:
- 8080:80
environment:
WORDPRESS_DB_PASSWORD: password
@odadoda
odadoda / routes
Created November 22, 2013 07:10
How the simplechat "routes" file routes the incoming requests
GET / controllers.Application.index()
GET /assets.javascript.ws.js controllers.Application.wsJs()
GET /wsInterface controllers.Application.wsInterface()
@odadoda
odadoda / Application.java:index()
Created November 8, 2013 13:14
Render index.html
// render index page
public static Result index() {
return ok(index.render());
}
@odadoda
odadoda / Application.java:wsInterface()
Created November 8, 2013 13:16
Return a websocket connection
// Websocket interface
public static WebSocket<String> wsInterface(){
return new WebSocket<String>(){
// called when websocket handshake is done
public void onReady(WebSocket.In<String> in, WebSocket.Out<String> out){
SimpleChat.start(in, out);
}
};
}
@odadoda
odadoda / SimpleClass.java
Created November 8, 2013 13:21
Taking care of websockets and in and out messages
package models;
import play.mvc.*;
import play.libs.*;
import play.libs.F.*;
import java.util.*;
public class SimpleChat{
@odadoda
odadoda / ws.js
Created November 8, 2013 13:23
Clientside
$(function(){
// get websocket class, firefox has a different way to get it
var WS = window['MozWebSocket'] ? window['MozWebSocket'] : WebSocket;
// open pewpew with websocket
var socket = new WS('@routes.Application.wsInterface().webSocketURL(request)');
var writeMessages = function(event){
$('#socket-messages').prepend('<p>'+event.data+'</p>');
@odadoda
odadoda / Application.java:wsJs()
Created November 8, 2013 13:15
Render the javascript file
// get the ws.js script
public static Result wsJs() {
return ok(views.js.ws.render());
}
@odadoda
odadoda / pngquant all
Created August 4, 2014 14:12
force replace all png with pngquant result
pngquant --ext .png --force *.png
@odadoda
odadoda / gist:c0da930a6cb1bc714dca
Last active August 29, 2015 14:01
pngquant example
pngquant --quality=70-99 input.png -o output.png