Skip to content

Instantly share code, notes, and snippets.

View ypetya's full-sized avatar
💭
🚀

Peter Kiss ypetya

💭
🚀
  • Budapest, Hungary
View GitHub Profile
package tools.cache;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class WeakValueHashMap<K,V> extends HashMap<K,V> implements Map<K, V> {
private HashMap<K,WeakReference<V>> mDatabase=new HashMap<K, WeakReference<V>>();
@ypetya
ypetya / GZip.java
Created September 5, 2014 09:04
Serialize and deserialize java Object into a bytearray containing GZIP-ped data.
package tools.distribution.transmission.serialization;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.logging.Level;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
@ypetya
ypetya / gist:2d358e38158562ff0e34
Last active August 29, 2015 14:04
hungarian build humor
Nyomj egy clean-t eastwood!
Mivel buildelsz ant-tal Jozsef?
THE BASIC LAWS OF HUMAN STUPIDITY
By Carlo M. Cipolla
illustrations by James Donnelly
Table of contents
The first basic law of human stupidity
The second basic law
The third (and golden) basic law
Frequency distribution
The power of stupidity
@ypetya
ypetya / Gruntfile.js
Created July 17, 2014 13:09
Gruntfile.js for angular-gettext example
module.exports=function(grunt){
grunt.loadNpmTasks('grunt-angular-gettext');
//This task will parse all our source files and extract the texts we want to have translated – the ones that have an associated translate directive – and add them to a so called pot file.
grunt.initConfig({
nggettext_extract:{ //we define the task name we want to configure or initialize
pot:{
files:{
'po/template.pot':['../templates/*.html'] //we want the task to parse all html files in the current directory or any sub directory of it and output the result of the task into a file called template.pot
}
}
@ypetya
ypetya / DeleteLongFilePathOnWindows.java
Last active August 29, 2015 14:03
Removes a windows gift... the too deep file system with java nio
package testapps.uncategorised;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class DeleteLongFilePathOnWindows {
String toRemove;
@ypetya
ypetya / 0_reuse_code.js
Created June 26, 2014 14:50
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ypetya
ypetya / collect.sh
Last active August 29, 2015 14:03
Create a helper bash function to collect documents on my computer
#!/bin/bash
function collect() {
OLD_IFS=$IFS
IFS=$'\n'
files=( $(
find /d/DEV -type f \( -iname \*.docx -o -iname \*.mobi -o -iname \*.doc -o -iname \*.pdf \)\
-not \( -path '*/.git/*' -o -path '*/.m2/*' -o -path '*/caches/*' -o -path '*/.svn/*' \) 2>/dev/null
))
for i in ${files[*]} ; do
@ypetya
ypetya / gist:3b2ebfcd7a56df527ed3
Last active August 29, 2015 14:01
PECS example
public static void getOldSeaAnimals(List<? extends SeaAnimal> animals, List<? super SeaAnimal> oldAnimals)
{
for (SeaAnimal animal:animals)
{
if (animal.getAge() > 100)
{
oldAnimals.add(animal);
}
}
}
@ypetya
ypetya / ssh-key-ok.sh
Last active August 29, 2015 14:01 — forked from lalyos/ssh-key-ok.sh
#!/bin/bash
mkdir -p .ssh
chmod 700 .ssh
cat >>~/.ssh/authorized_keys<<EOF
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAwI/RmvE2TG+LVUwnJho4i+evr7ZuN8T2xAfffJUNoz5KUHScN0tvOIALCQsNE7iJicUVV1PEUz0pBnWliU+UCsjhHuogbWQ13t/GHxIzmoWZrXcFCMLQ9yHv3yr/1WVyLzPWpKRRDeZ5vSGGnP4wHMpI3qZxUnSNn51VLILdDOutLwtBEpW7QjnlO9gIhipGJIHaPF10WorJGJRoMLzNAb/rRwEKwFXRAI0PwJ46dJs1GkxGEWY8+2WPd6kQ0i3kJzEFmD08kSsHPgo8RPuCmWGSoDWY5mBReIEWNyH1v/rQLSnfWR2OfRihIe7J49UKYur2yX9yzRn1aRw2Y9+R9w== [email protected]
EOF
chmod 644 ~/.ssh/authorized_keys