Skip to content

Instantly share code, notes, and snippets.

@mabako
mabako / stats.php
Created May 12, 2010
Statistics for valhallaGaming repos
View stats.php
mabako: 553814 (44.65%) lines, 3549 (54.38%) files
Mount: 363479 (29.31%) lines, 1172 (17.96%) files
Fenix: 240925 (19.43%) lines, 1463 (22.42%) files
Chamberlain: 51597 (4.16%) lines, 298 (4.57%) files
herbjr: 13238 (1.07%) lines, 18 (0.28%) files
Cazomino05: 5826 (0.47%) lines, 0 (0%) files
Flobu: 4733 (0.38%) lines, 10 (0.15%) files
VGMTAServer: 1751 (0.14%) lines, 1 (0.02%) files
Mr.Hankey: 1709 (0.14%) lines, 0 (0%) files
Jumba: 1187 (0.1%) lines, 3 (0.05%) files
View maketime.lua
local function isYearALeapYear(year)
if not year then
year = getRealTime().year + 1900
end
if (year % 4 == 0 and year % 100 ~= 0) or year % 400 == 0 then
return true
else
return false
end
end
@mabako
mabako / PrintExample.java
Created May 29, 2012
Simple way to print Java GUI elements
View PrintExample.java
// beliebige Komponente
final Component component = ...;
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(new Printable()
{
@Override
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException
{
@mabako
mabako / Dashboard.java
Created May 29, 2012
TableView thing for databases
View Dashboard.java
package net.mabako.zwickau.autohaendler;
import javax.swing.JButton;
public class Dashboard extends JPanel
{
/**
* Serial
*/
private static final long serialVersionUID = -2754350246072768836L;
@mabako
mabako / UserTable.java
Created Jun 15, 2012
User management in SQL Server 2008 R2
View UserTable.java
package net.mabako.zwickau.db;
import static net.mabako.zwickau.autohaendler.G.db;
import java.util.Vector;
public class UserTable extends TableHandler
{
/**
* {@inheritDoc}
@mabako
mabako / decode.lua
Created Jun 28, 2012
lua € thing, unicode(like utf16)->utf8
View decode.lua
:gsub("&#%d%d%d%d;", decode)
function decode(str)
local num = tonumber(str:sub(3,6))
local first = math.floor(num/4096)
num = num - 4096 * first
return string.char(first+224, math.floor(num/64)+128, num%64+128)
end
@mabako
mabako / gist:4037837
Created Nov 8, 2012
java: read string into file
View gist:4037837
/**
* Read complete file into a String
*/
try(InputStream is = ...) {
try(Scanner s = new Scanner(is).useDelimiter("\\A")) {
return s.hasNext() ? s.next() : "";
}
}
View gist:6923490
(define (primHelp num count)
(cond
((zero? (modulo num count)) #f)
((< count (sqrt num)) (primHelp num (+ count 1)))
(else #t)
)
)
@mabako
mabako / max-square-sum.scm
Created Oct 11, 2013
Calculates the sum of the squares of the two largest numbers in the list
View max-square-sum.scm
(define (a8 a . r)
(let
(
(m (apply max r))
)
(if (>= a m)
(+ (quadrat a) (quadrat m))
(apply a8 (append r (list a)))
)
)
@mabako
mabako / euklid.scm
Created Oct 11, 2013
euclidian algorithm
View euklid.scm
(define (euklid a b)
(if (= b 0) a (euklid b (modulo a b)))
)
(print (euklid 1071 1029))
(print (euklid 1029 1071))