Skip to content

Instantly share code, notes, and snippets.

View bjorn-ali-goransson's full-sized avatar

Björn Ali Göransson bjorn-ali-goransson

View GitHub Profile
import java.io.DataOutputStream;
import java.net.ServerSocket;
public class Server {
public static void main(String[] args) throws Exception{
new DataOutputStream(new ServerSocket(80).accept().getOutputStream()).writeBytes("Hello, world!");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<servlet>
<servlet-name>hej</servlet-name>
<servlet-class>ServletTest</servlet-class>
</servlet>
@bjorn-ali-goransson
bjorn-ali-goransson / index.htm
Last active August 29, 2015 13:57
Minimal Bootstrap + FontAwesome HTML page
<!DOCTYPE html>
<html><head>
<meta charset="utf-8">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
</head><body>
<div class="container"><a class="btn btn-success" href="http://ow.ly/uf5n0"><i class="fa fa-star fa-spin"></i></a></div>
</body></html>
@bjorn-ali-goransson
bjorn-ali-goransson / webserver.java
Created March 5, 2014 09:02
Webserver version 2
import java.io.DataOutputStream;
import java.net.ServerSocket;
import java.util.Date;
public class WebServerTest {
public static void main(String[] args) throws Exception{
String newLine = "\n";
System.out.println("Starting server...");
@bjorn-ali-goransson
bjorn-ali-goransson / webserver.java
Created March 5, 2014 09:38
Web Server, last version (including regression)
import java.io.DataOutputStream;
import java.net.ServerSocket;
import java.util.Date;
public class WebServerTest {
public static void main(String[] args) throws Exception{
System.out.println("Starting server...");
@bjorn-ali-goransson
bjorn-ali-goransson / index.html
Last active July 5, 2018 07:13
Minimal Bootstrap+jQuery+BootstrapJS+FontAwesome template
<!DOCTYPE html>
<html><head>
<meta charset="utf-8">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
</head><body>
<div class="container"><span class="btn btn-success"><i class="fa fa-coffee"></i></span></div>
</body></html>
@bjorn-ali-goransson
bjorn-ali-goransson / index.jsp
Created March 6, 2014 09:05
JSP that check free memory
<!DOCTYPE html>
<html><head>
<meta charset="utf-8">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<style>
body{background:url('mostar-bosnia.jpg');}
.container{margin-top:200px;text-align:center;}
@bjorn-ali-goransson
bjorn-ali-goransson / students.jsp
Last active August 29, 2015 13:57
Students application (demo of spaghetti code)
<%@page import="java.sql.*" %>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE html>
<html><head>
<meta charset="utf-8">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
@bjorn-ali-goransson
bjorn-ali-goransson / Student.java
Created March 10, 2014 05:19
Java code for 99 Students with fake names
public class Student {
public Integer id;
public String name;
public String surname;
public String icon;
public Student(Integer id, String name, String surname, String icon){
this.id = id;
this.name = name;
this.surname = surname;
@bjorn-ali-goransson
bjorn-ali-goransson / students.sql
Created March 16, 2014 23:34
99 students with table name "student"
INSERT INTO `student` VALUES (1,'Rachel','Morgan','wrench');
INSERT INTO `student` VALUES (2,'Craig','Taylor','minus');
INSERT INTO `student` VALUES (3,'Jean','King','legal');
INSERT INTO `student` VALUES (4,'Jacqueline','Stewart','key');
INSERT INTO `student` VALUES (5,'Jerry','Thompson','microphone-slash');
INSERT INTO `student` VALUES (6,'Annie','Allen','leaf');
INSERT INTO `student` VALUES (7,'Doris','Bailey','gift');
INSERT INTO `student` VALUES (8,'Judith','Wood','calendar-o');
INSERT INTO `student` VALUES (9,'Harry','Reed','flag-checkered');
INSERT INTO `student` VALUES (10,'Sara','Edwards','flag');