Skip to content

Instantly share code, notes, and snippets.

@Suleiman19
Suleiman19 / Spinner Setup (Activity)
Last active October 11, 2022 14:10
Theme Aware Material Design Spinner
Spinner spinner = (Spinner) findViewById(R.id.main_spinner);
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getSupportActionBar().getThemedContext(),
R.layout.spinner_list_style,
getResources().getStringArray(R.array.countries));
spinnerAdapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
spinner.setAdapter(spinnerAdapter);
@tatocaster
tatocaster / RealPathUtil.java
Last active April 3, 2024 00:27
Real Path Utility class for Android, works for all API
public class RealPathUtil {
public static String getRealPath(Context context, Uri fileUri) {
String realPath;
// SDK < API11
if (Build.VERSION.SDK_INT < 11) {
realPath = RealPathUtil.getRealPathFromURI_BelowAPI11(context, fileUri);
}
// SDK >= 11 && SDK < 19
else if (Build.VERSION.SDK_INT < 19) {
@myusuf3
myusuf3 / delete_git_submodule.md
Created November 3, 2014 17:36
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@broady
broady / 1MarkerAnimation.java
Last active March 13, 2024 12:44
Animating Markers
/* Copyright 2013 Google Inc.
Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0.html */
package com.example.latlnginterpolation;
import android.animation.ObjectAnimator;
import android.animation.TypeEvaluator;
import android.animation.ValueAnimator;
import android.annotation.TargetApi;
import android.os.Build;
@eugenehp
eugenehp / reverse-ip-lookup.js
Created July 8, 2012 14:58
node.js IP reverse lookup
var dns = require('dns');
function reverseLookup(ip) {
dns.reverse(ip,function(err,domains){
if(err!=null) callback(err);
domains.forEach(function(domain){
dns.lookup(domain,function(err, address, family){
console.log(domain,'[',address,']');
console.log('reverse:',ip==address);