Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Delivering

Paweł Hajduk phajduk

🎯
Delivering
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am phajduk on github.
  • I am phajduk (https://keybase.io/phajduk) on keybase.
  • I have a public key whose fingerprint is 98FF C974 7825 E640 9EA9 2AA1 7571 470A C2F4 89CC

To claim this, I am signing this object:

View UrlHelper.java
public class UrlHelper {
public static Map<String, String> splitQuery(String query) {
Map<String, String> queryPairs = new LinkedHashMap<>();
String[] pairs = query.split("&");
for(String pair : pairs) {
int idx = pair.indexOf("=");
try {
queryPairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"), URLDecoder.decode(pair.substring(idx + 1), "UTF-8"));
} catch(UnsupportedEncodingException e) {
Timber.e(e, "Problem during parsing query args");
@phajduk
phajduk / gist:2e28254c6e1ecad37785
Created Jun 4, 2014
Getting mime type from file
View gist:2e28254c6e1ecad37785
Uri path = Uri.fromFile(file);
MimeTypeMap typeMap = MimeTypeMap.getSingleton();
String extension = MimeTypeMap.getFileExtensionFromUrl(path.toString()).toLowerCase();
if (extension.contains(".")) {
extension = extension.substring(extension.lastIndexOf("."));
}
String mimeType= typeMap.getMimeTypeFromExtension(extension);