Skip to content

Instantly share code, notes, and snippets.

View mattvryan's full-sized avatar

Matt Ryan mattvryan

View GitHub Profile
package org.mvryan.http;
import static io.netty.buffer.Unpooled.copiedBuffer;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
@mattvryan
mattvryan / bash_check_java_version
Created January 20, 2015 17:05
Bash script snippet to check Java version (e.g. in an init script)
JAVA=`which java`
JAVA_VERSION=$("$JAVA" -version 2>&1 | awk -F '"' '/version/ {print $2}' | sed 's/\(.*\)\.\(.*\)\..*/\1\2/')
if [ "$JAVA_VERSION" -lt 17 ]; then
echo "Invalid Java version found - must be at least 1.7"
exit 1
fi
@mattvryan
mattvryan / MySQL_INSERT_WHERE_NOT_EXISTS_non_indexed
Created October 15, 2014 17:23
MySQL "INSERT ... WHERE NOT EXISTS" if you don't have/know a primary/unique key
INSERT INTO my_table (unique_but_non_indexed_col1, col2, col3)
SELECT * FROM (SELECT 'unique_val1', 'val2', 'val3') AS tmp
WHERE NOT EXISTS (
SELECT id FROM my_table WHERE unique_but_non_indexed_col1='unique_val1'
) LIMIT 1;
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="2">
<profile kind="CleanUpProfile" name="Matt's Profile" version="2">
<setting id="cleanup.qualify_static_method_accesses_with_declaring_class" value="false"/>
<setting id="cleanup.always_use_this_for_non_static_method_access" value="false"/>
<setting id="cleanup.organize_imports" value="true"/>
<setting id="cleanup.remove_trailing_whitespaces_ignore_empty" value="false"/>
<setting id="cleanup.format_source_code_changes_only" value="false"/>
<setting id="cleanup.qualify_static_field_accesses_with_declaring_class" value="false"/>
<setting id="cleanup.add_generated_serial_version_id" value="false"/>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="12">
<profile kind="CodeFormatterProfile" name="Matt's Profile" version="12">
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="next_line"/>
@mattvryan
mattvryan / gitified_bash_profile
Created October 22, 2013 22:42
Cool .bash_profile add-on with convenient aliases for git commands and a useful prompt that shows the branch you are in. Thanks to BenGlasser and bpedman.
# git commamands simplified
alias gst='git status'
alias gco='git checkout'
alias gci='git commit'
alias grb='git rebase'
alias gbr='git branch'
alias glg='git log --date-order --all --graph --format="%C(green)%h%Creset %C(yellow)%an%Creset %C(blue bold)%ar%Creset %C(red bold)%d%Creset%s"'
alias glg2='git log --date-order --all --graph --name-status --format="%C(green)%H%Creset %C(yellow)%an%Creset %C(blue bold)%ar%Creset %C(red bold)%d%Creset%s"'
## PROMPT ##