Skip to content

Instantly share code, notes, and snippets.

John Ryan jtryan

Block or report user

Report or block jtryan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jtryan
jtryan / .bashrc
Created Feb 19, 2019 — forked from miguelmota/.bashrc
Show host IP address on your bash prompt.
View .bashrc
# Show host IP address on your bash prompt.
#
# Example of prompt:
#
# moogs@192.168.1.100 : ~/Dropbox/workspace
# $
#
export PS1="\n\n\[\033[0;36m\]\u@$(ifconfig | grep "inet " | grep -v 127.0.0. | awk '{print $2}')\[\033[00m\]\[\033[0;32m\] : \w\[\033[00m\]\n\[\033[00;32m\]\$\[\033[00m\] "
export PS2="\[\033[0;32m\]>\[\033[00m\] "
View pi 3 B .vimrc
set nocompatible
set tabstop=4
set shiftwidth=4
set expandtab
set hlsearch
set incsearch
set guioptions-=e
@jtryan
jtryan / opencv3-osx.md
Last active Apr 26, 2018
opencv3 on os x - April 2018
View opencv3-osx.md

Brew has changed the opncv3 cask.

It is now part of core and has lost the ability to use cli argument on install

  1. Install brew
  2. brew install python
  3. brew install python3
  4. brew install opencv
  5. pip install virtualenv virtualenvwrapper

Now do some cleanup.

@jtryan
jtryan / git-branch-to-master.md
Created Feb 22, 2017
Moving branch to master in git
View git-branch-to-master.md

The problem with the other two answers is that the new master doesn't have the old master as an ancestor, so when you push it, everyone else will get messed up. This is what you want to do:

git checkout better_branch
git merge --strategy=ours master    # keep the content of this branch, but record a merge
git checkout master
git merge better_branch             # fast-forward master up to the merge

If you want your history to be a little clearer, I'd recommend adding some information to the merge commit message to make it clear what you've done. Change the second line to:

@jtryan
jtryan / vidcap_ex.py
Created Feb 21, 2017
Capture video Frame
View vidcap_ex.py
vidcap = cv2.VideoCapture('test_video.mp4')
vidcap.set(cv2.CAP_PROP_POS_MSEC,38000) # just cue to 38 sec. position
success, image = vidcap.read()
if success:
cv2.imwrite("capture.jpg", image) # save frame as JPEG file
cv2.imshow("final_frame",image)
cv2.waitKey()
@jtryan
jtryan / docker-container-clean.md
Created Nov 7, 2016
Clean up those containers
View docker-container-clean.md
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
View ValidatingHttpRequest.java
package com.sigilius.utility;
import sun.text.Normalizer;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.validation.ValidationException;
import java.util.regex.Pattern;
View ValidatingHttpRequest.java
// Return HTML Entity code equivalents for any special characters
public static String HTMLEntityEncode( String input ) {
StringBuffer sb = new StringBuffer();
for ( int i = 0; i < input.length(); ++i ) {
char ch = input.charAt( i );
if ( ch>='a' && ch<='z' || ch>='A' && ch<='Z' || ch>='0' && ch<='9' ) {
@jtryan
jtryan / uuid.md
Created Aug 15, 2016
UUID base 64 Java
View uuid.md
@jtryan
jtryan / StateSavingArrayAdapter.java
Created Aug 14, 2016 — forked from curioustechizen/StateSavingArrayAdapter.java
StateSavingArrayAdapter: An ArrayAdapter that knows how to save/restore its own state.
View StateSavingArrayAdapter.java
/**
* <p>
* An {@code ArrayAdapter} that also knows how to save and restore its state.
* Basically all it does is save/restore the array of objects being managed by
* the Adapter.
* </p>
*
* <p>
* Note that this only saves the items and not things like checked item
* positions. Those belong to the {@link ListView} itself. Consider using
You can’t perform that action at this time.