Skip to content

Instantly share code, notes, and snippets.

@jtryan
jtryan / gitRevert.md
Last active November 25, 2015 16:01
For when Git commit goes wrong

Undo a commit and redo

$ git commit ...              (1)

$ git reset --soft HEAD~1     (2)

<< edit files as necessary >> (3)

$ git add ....                (4)
@jtryan
jtryan / Update-Git.md
Created November 25, 2015 16:02
Update fork directly on Github.com

http://www.hpique.com/2013/09/updating-a-fork-directly-from-github/

Here’s how to update your fork directly from GitHub (as shown in the video above):

  1. Open your fork on GitHub.
  2. Click on Pull Requests.
  3. Click on New Pull Request. By default, GitHub will compare the original with your fork, and there shouldn’t be anything to compare if you didn’t make any changes.
  4. Click on switching the base (if no changes were made in the fork) or click Edit and switch the base manually. Now GitHub will compare your fork with the original, and you should see all the latest changes.
  5. Click on Click to create a pull request for this comparison and assign a predictable name to your pull request (e.g., Update from original).
@jtryan
jtryan / npmClean.md
Created November 25, 2015 16:03
Clean up for NPM issues

This housecleaning worked for me:

mv /usr/local/lib/node_modules /tmp rm -rf /tmp/node_modules/npm curl https://www.npmjs.com/install.sh | sh npm cache clean npm install -g $(ls -1rt /tmp/node_modules/)

@jtryan
jtryan / android_onCick.md
Last active July 24, 2016 12:51
Android OnClick for layout

#Add onClick for layout

RelativeLayout layout = (RelativeLayout)findViewById(R.id.rv_layout);
layout.setOnClickListener(new View.OnClickListener()
{
    @Override
    public void onClick(View v)
    {
 // Do Actions
@jtryan
jtryan / onclickEmailIntent.md
Created July 24, 2016 20:44
Android email Intent
// Find the View that shows the ContactUs  category
        TextView contactUs = (TextView) findViewById(R.id.contact);

        // Set a click listener on view
        if (contactUs != null) {
            contactUs.setOnClickListener(new View.OnClickListener() {
@jtryan
jtryan / adapterCLickListener.md
Last active August 10, 2016 13:45
Android Set click listener in adapter
@Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final Context mContext = getContext();
        final ViewHolder holder;
        final Earthquake currentEarthquake = (Earthquake) getItem(position);

        if (convertView == null) {
            convertView = LayoutInflater.from(getContext()).inflate(
                    R.layout.earthquake_list_item, parent, false);
@jtryan
jtryan / StateSavingArrayAdapter.java
Created August 14, 2016 02:18 — forked from curioustechizen/StateSavingArrayAdapter.java
StateSavingArrayAdapter: An ArrayAdapter that knows how to save/restore its own state.
/**
* <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
@jtryan
jtryan / uuid.md
Created August 15, 2016 17:29
UUID base 64 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 / ValidatingHttpRequest.java
Last active October 18, 2016 14:43
Validation headers
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;