Skip to content

Instantly share code, notes, and snippets.

@xzzz9097
xzzz9097 / classdump.m
Created December 3, 2016 21:03
DFRFoundation.framework dumps
//
// File: /System/Library/PrivateFrameworks/DFRFoundation.framework/Versions/A/DFRFoundation
// UUID: C3548955-29E4-3B77-BB2D-687FDA287B87
//
// Arch: x86_64
// Current version: 104.2.0
// Compatibility version: 1.0.0
// Source version: 104.2.0.0.0
// Minimum Mac OS X version: 10.12.0
// SDK version: 10.12.0
@xzzz9097
xzzz9097 / removeSpaces.java
Created September 28, 2014 17:20
Simple static method that removes spaces from a string
/**
* Removes spaces from a string
* @param raw - the string with spaces
* @return - the string without spaces
*/
public static String removeSpaces(String raw) {
return raw.replace(" ", "");
}
@xzzz9097
xzzz9097 / 0_reuse_code.js
Last active August 29, 2015 14:06
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
@xzzz9097
xzzz9097 / stringInString.java
Last active August 29, 2015 14:06
Java - Insert a string into another string
/**
* Function that inserts a specified string into another string. It uses java's StringBuilder.
* Usage: insertStringInString("dogs cats", "and", 4) -> "dogs and cats"
* @param string - The main string that should contain the new piece
* @param insertion - The piece to add
* @param position - The position from which to add the piece
* @return - The final string
*/
public static String insertStringInString(String string, String insertion, int position) {
// Only insert if the position is > -1 (useful with string.indexOf which returns -1
@xzzz9097
xzzz9097 / onTouchClick.java
Last active August 29, 2015 14:06
Check if a particular touch event on a view is a click with onTouch instead of onClick.
/**
* Handy method that pairs with onTouchEvent to determine when the event is a click action.
* Works by checking difference from initial to final finger position and the duration of the
* event (to make sure event is not a long click).
* @param startX: initial position of the finger - for instance event.getX() in ACTION_DOWN
* @param endX: final position of the finger - for instance event.getX() in ACTION_UP
* @param duration: duration of the touch - has to be implemented
* @return whether the event is a click or not
*/
private boolean isAClick(float startX, float endX, long duration) {
@xzzz9097
xzzz9097 / removePartOfString.java
Last active August 29, 2015 14:05
Remove part of string - Java
/**
* Quick method to remove a specified part of a string
* @param remove - the string part to remove
* @param from - the original string
* @return - the cut string
*/
public static String removeStringFromString(String remove, String from) {
char lastCharacter = remove.charAt(remove.length() - 1);
int cutStart = from.lastIndexOf(lastCharacter) + 1;
return from.substring(cutStart);
@xzzz9097
xzzz9097 / CustomEditText.java
Last active June 12, 2020 09:53
Android EditText with key back event listener
package com.edge.utils;
import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ListView;