Skip to content

Instantly share code, notes, and snippets.

View Manabu-GT's full-sized avatar

Manabu S. Manabu-GT

  • N/A (private)
  • Boulder, USA
View GitHub Profile
@Manabu-GT
Manabu-GT / input.java
Last active February 7, 2017 06:36
TODO: Hackerrank Input Template
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
@Manabu-GT
Manabu-GT / activity_from_view.java
Last active January 29, 2017 09:52
Get an Activity Context within a View
private Activity getActivity() {
Context context = getContext();
while (context instanceof ContextWrapper) {
if (context instanceof Activity) {
return (Activity)context;
}
context = ((ContextWrapper)context).getBaseContext();
}
return null;
}
@Manabu-GT
Manabu-GT / ShareViewController.swift
Last active July 28, 2020 03:14
[WIP] Receiving Location data from Apple Map using Share Extension
override func didSelectPost() {
// This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments.
// Inform the host that we're done, so it un-blocks its UI. Note: Alternatively you could call super's -didSelectPost, which will similarly complete the extension context.
NSLog("Content Text: %@", self.contentText)
NSLog("Input Count: %d", self.extensionContext!.inputItems.count)
let inputItem: NSExtensionItem = self.extensionContext?.inputItems[0] as! NSExtensionItem
@Manabu-GT
Manabu-GT / ShareLocation.swift
Last active September 27, 2016 11:07
Share Location data with vCard format on iOS using UIActivityViewController
import CoreLocation
func shareLocation(coordinate:CLLocationCoordinate2D) -> Void {
guard let cachesPathString = NSSearchPathForDirectoriesInDomains(.CachesDirectory, .UserDomainMask, true).first else {
print("Error: couldn't find the caches directory.")
return
}
let vCardString = [
@Manabu-GT
Manabu-GT / gist:62cbd9440ba9f10dcbaa
Created May 22, 2015 05:05
android gradle - capture all variants
project.configure(project) {
if (it.hasProperty("android")) {
tasks.whenTaskAdded { task ->
project.("android").applicationVariants.all { variant ->
println "${variant.name.capitalize()}"
println "${variant.buildType.name}"
}
}
}
}
@Manabu-GT
Manabu-GT / .gitignore
Last active August 29, 2015 14:14
.gitignore for Android Studio
# Local configuration file (sdk path, keystore pass, etc)
local.properties
keystore.properties
# Gradle
.gradle
build/
# Android Studio Project files
*.iml
@Manabu-GT
Manabu-GT / gist:b8abc95cd15b7c547169
Created January 15, 2015 09:09
Mosaic RenderScript
#pragma version(1)
#pragma rs java_package_name(com.uievolution.vehicleinfo.android.util)
#pragma rs_fp_relaxed
rs_allocation pixels;
int dotSize;
void init() {
}
@Manabu-GT
Manabu-GT / googleMapMyLocation
Last active March 14, 2017 05:31
Android - adjust google map's my location button
//HACK: Get the button view and place it on the bottom right (as Google Maps app)
View locationButton = ((View) mMapFragment.getView().findViewById(1).getParent()).findViewById(2);
RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) locationButton.getLayoutParams();
rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
rlp.setMargins(0, 0, 30, 30);