Skip to content

Instantly share code, notes, and snippets.

@phstudy
phstudy / mock_location_detection.patch
Last active February 11, 2019 14:32
revert CVE-2017-0489 for mock location detection (Android 2017-03-01 security patch)
diff --git a/services/core/java/com/android/server/LocationManagerService.java b/services/core/java/com/android/server/LocationManagerService.java
index 7b02a4fb3fd..04006c36e5a 100644
--- a/services/core/java/com/android/server/LocationManagerService.java
+++ b/services/core/java/com/android/server/LocationManagerService.java
@@ -73,7 +73,6 @@ import android.provider.Settings;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
-import android.util.EventLog;
import android.util.Log;
@phstudy
phstudy / GoogleTokenUtils.java
Created December 3, 2018 09:33
calculate SAPISIDDASH
import com.google.common.hash.Hashing;
import java.nio.charset.Charset;
public class GoogleTokenUtils {
public static String calcSapiSidDash(long ts, String sapiSid, String origin) {
return String.format("%d_%s", ts, calcHash(ts, sapiSid, origin));
}
public static String calcSapiSidDash(String sapiSid, String origin) {
@phstudy
phstudy / patch.diff
Created October 6, 2018 08:30
Patch for Paragon NTFS & HFS+ for Linux 9.5 to support Kernel 4.15.x
diff --git a/ifslinux/ufsdjnl.c b/ifslinux/ufsdjnl.c
index f3e55bc..bcbeef5 100644
--- a/ifslinux/ufsdjnl.c
+++ b/ifslinux/ufsdjnl.c
@@ -1403,7 +1403,7 @@ jnl_alloc(
BUG_ON( size & ( size-1 ) ); // Must be a power of 2
- flags |= __GFP_REPEAT;
+ flags |= __GFP_RETRY_MAYFAIL;
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSck.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSck.java
index 10b0012016b..6f53ee436ba 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSck.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSck.java
@@ -210,6 +210,11 @@ private Integer listCorruptFileBlocks(String dir, String baseUrl)
allDone = true;
break;
}
+ if (line.startsWith("Access denied for user")) {
+ numCorrupt = 0;
@phstudy
phstudy / HyperLogLogStoreUDAF.scala
Created June 6, 2017 17:12 — forked from MLnick/HyperLogLogStoreUDAF.scala
Experimenting with Spark SQL UDAF - HyperLogLog UDAF for distinct counts, that stores the actual HLL for each row to allow further aggregation
class HyperLogLogStoreUDAF extends UserDefinedAggregateFunction {
override def inputSchema = new StructType()
.add("stringInput", BinaryType)
override def update(buffer: MutableAggregationBuffer, input: Row) = {
// This input Row only has a single column storing the input value in String (or other Binary data).
// We only update the buffer when the input value is not null.
if (!input.isNullAt(0)) {
if (buffer.isNullAt(0)) {
@phstudy
phstudy / gist:fdf40c04feb1b52c99e7bc2fe843bf56
Created June 1, 2017 15:11 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
@phstudy
phstudy / gist:c180afa138325a4bd8fe7c566d1ed839
Created June 1, 2017 15:11 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
@phstudy
phstudy / install.md
Created June 1, 2017 15:10 — forked from hlb/Brewfile
clean install

System Preferences

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
defaults write NSGlobalDomain InitialKeyRepeat -int 12

# Set a blazingly fast keyboard repeat rate
@phstudy
phstudy / core-site.xml.template
Last active April 5, 2017 08:11
azure blob storage core-site.xml.template
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration xmlns:xi="http://www.w3.org/2001/XInclude">
<!--
<property>
<name>fs.azure.account.key.{WASB_ACCOUNT_NAME}.blob.core.windows.net</name>
<value>{WASB_ACCOUNT_KEY}</value>
</property>
@phstudy
phstudy / Iterables.java
Last active June 4, 2016 16:59 — forked from popcornylu/Iterables.java
Iterable transformation
import org.apache.commons.collections4.IterableUtils;
import java.util.function.Function;
public class Iterables {
public static <F, T> Iterable<T> map(
Iterable<F> iterable,
Function<F, T> mapper) {
return IterableUtils.transformedIterable(iterable, (x) -> mapper.apply(x));
}