Skip to content

Instantly share code, notes, and snippets.

View ypetya's full-sized avatar
💭
🚀

Peter Kiss ypetya

💭
🚀
  • Budapest, Hungary
View GitHub Profile
@ypetya
ypetya / bash.md
Created May 10, 2014 11:10
order of sourcing profile, bashrc and bash_profile

profile order

package testapps.networking;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.Scanner;
@ypetya
ypetya / MidiFractal.java
Created May 9, 2014 11:42
This file plays a random music
package testapps.sound.midi;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import javax.sound.midi.MidiChannel;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Synthesizer;
@ypetya
ypetya / install_my_dotfiles_repo.sh
Last active August 29, 2015 14:01
dotfile repo install script
#!/bin/bash
REQUIREMENTS=( git curl vim )
REPO=https://bitbucket.org/kisp/dotfiles.git
VIMFILES_REPO=https://github.com/ypetya/vimfiles.git
function require() {
echo "require $1"
if ! type -t $1 2>&1 >> /dev/null ; then
echo "$1 not installed yet!"
@ypetya
ypetya / FileWatcher.java
Last active August 29, 2015 13:57
Watch filesystem java7 nio example code
package tools;
import java.io.IOException;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import static java.nio.file.LinkOption.NOFOLLOW_LINKS;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
@ypetya
ypetya / loadJMXAgent.java
Last active September 2, 2016 16:15
Starting up jmx remote agent on a specified port in case it was not started by the JVM. (No jmxremote jvm arg specified on startup )
public static String loadJMXAgent(int port) throws IOException,
AttachNotSupportedException, AgentLoadException,
AgentInitializationException {
String name = ManagementFactory.getRuntimeMXBean().getName();
VirtualMachine vm = VirtualMachine.attach(name.substring(0,
name.indexOf('@')));
String lca = vm.getAgentProperties().getProperty(
"com.sun.management.jmxremote.localConnectorAddress");
if (lca == null) {
#!/bin/bash
#set -x
# Shows you the largest objects in your repo's pack file.
# Written for osx.
#
# @see http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
# @author Antony Stubbs
# set the internal field spereator to line break, so that we can iterate easily over the verify-pack output
@ypetya
ypetya / .bashrc
Created September 29, 2013 13:19
find a jar of class from MinGw. gitbash
# this function helps you to find a jar file for the class
function find_jar_of_class() {
OLD_IFS=$IFS
IFS=$'\n'
jars=( $( find -type f -name "*.jar" ) )
for i in ${jars[*]} ; do
if [ ! -z "$(jar -tvf "$i" | grep -Hsi $1)" ] ; then
echo "$i"
fi
@ypetya
ypetya / .bashrc
Created September 29, 2013 13:11
Created this 'ln' function into my .bashrc, it emulates a 'cp' call instead of the real 'ln -s' which is not supported on windows MinGw.
function ln() {
echo "WARNING! 'ln' is an unsupported command on this platform."
echo " * The following command was called:"
echo "ln $@"
if [ $1 = "-s" ] ; then
echo " * Trying to translate it to a simple copy command : "
COMMAND="cp -R $2 $3"
echo "$COMMAND"
@ypetya
ypetya / .bashrc
Last active December 19, 2015 08:29
ssh Host completion by .ssh/config and known_hosts files in case their exists.
# ssh completion
if [ -f ~/.ssh/config ] ; then
SSH_COMPLETE=( $(grep "^Host " ~/.ssh/config | cut -f2 -d ' ' | sort -u ) )
SSH_COMPLETE=( ${SSH_COMPLETE[*]} $(grep "\w*User " ~/.ssh/config | cut -f2 -d ' ' | sort -u ) )
fi
if [ -f ~/.ssh/known_hosts ] ; then
SSH_COMPLETE=( ${SSH_COMPLETE[*]} $(cut -f1 -d' ' ~/.ssh/known_hosts | cut -f1 -d',' | sort -u ))
fi
complete -o default -W "${SSH_COMPLETE[*]}" ssh
complete -o default -W "${SSH_COMPLETE[*]}" scp