Skip to content

Instantly share code, notes, and snippets.

View bonifaido's full-sized avatar

Nándor István Krácser bonifaido

View GitHub Profile
@bonifaido
bonifaido / PolynomialFitter.java
Created June 2, 2011 13:20 — forked from sanity/PolynomialFitter.java
Horner's method is a much faster evaluation
/***************************************************************************
* Copyright (C) 2009 by Paul Lutus, Ian Clarke *
* [email protected], [email protected] *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
@bonifaido
bonifaido / formattedtime.c
Created August 26, 2011 09:15
This small program prints a timestamp with milliseconds included
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
void printTime()
{
char buffer[32];
struct timeval timevalue;
struct tm *timeinfo;
@bonifaido
bonifaido / watch
Created September 8, 2011 11:45
Watch for Solaris
#!/bin/bash
usage() {
echo "usage: `basename $0` [-n secs] command"
}
if [ $# -eq 0 ]
then
usage
exit 1
@bonifaido
bonifaido / is-prime.clj
Created December 6, 2011 09:52
Detects if given integer is a prime?
; Clojure step 1
(defn is-prime? [n]
"Detects if input paramter is a prime."
(if (<= n 3)
true
(let [max (Math/floor (Math/sqrt n))]
(loop [d 2]
(if (zero? (rem n d))
false
@bonifaido
bonifaido / GZipTest.java
Created December 13, 2011 19:04
Correct unzipping with Java
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.GZIPInputStream;
public class GZipTest {
public static void main(String[] args) throws IOException {
@bonifaido
bonifaido / gist:1723274
Created February 2, 2012 12:36
Delete a line from a file with CLI
#!/usr/bin/bash
if [ $# != 2 ] ; then
echo $0 [FILE] [LINENUMBER]
fi
{ rm $1 && awk '{ if (NR != DEL) print }' DEL=$2 > $1; } < $1
(ns json-bench.core
(:require [cheshire.core :as cheshire])
(:require [clojure.data.json :as json])
(:require [clj-json.core :as clj-json]))
(defn nano-time []
(System/nanoTime))
(defn timed [task]
(let [t-start (nano-time)
@bonifaido
bonifaido / findclass.sh
Created March 22, 2012 14:09
Finds a class in a library of JARs
#!/usr/bin/bash
if [ $# != 2 ]
then
echo usage: findclass [CLASS] [DIR]
exit 1
fi
jars=(`find $2 -name '*.jar'`)
@bonifaido
bonifaido / oql_recipes.js
Last active January 21, 2022 08:00
VisualVM OQL Recipes
// The MIT License (MIT)
//
// Copyright (c) 2015 Nandor Kracser
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@bonifaido
bonifaido / gist:3067251
Created July 7, 2012 17:22
git - counting the number of source lines
# Change the regex group to your programming language's extensions
git ls-files | egrep '\.(h|cpp)$' | xargs cat | wc -l