Skip to content

Instantly share code, notes, and snippets.

@hkurosawa
hkurosawa / gist:1822617
Created February 14, 2012 02:22
Adding Admob banner to PhoneGap App
public class PhonegapWithAdmobActivity extends DroidGap {
private AdView adView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
adView = new AdView(this, AdSize.BANNER, PUBLISHER_ID);
super.loadUrl("file:///android_asset/www/index.html");
((LinearLayout)appView.getParent()).addView(adView);
adView.loadAd(new AdRequest());
}
@hkurosawa
hkurosawa / gist:2049459
Created March 16, 2012 10:23
Playing sound file in assets folder on Android
import android.media.MediaPlayer;
public class PlayerExample {
MediaPlayer p = null;
private void playSound(String fileName) {
p = new MediaPlayer();
try {
AssetFileDescriptor afd = ctx.getAssets().openFd(fileName);
p.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
afd.close();
@hkurosawa
hkurosawa / gist:2061125
Created March 17, 2012 15:24
Checks if the Android Device can handle certain Intent
public boolean canRespondToIntent(Context ctx, Intent i) {
PackageManager pm = ctx.getPackageManager();
List<ResolveInfo> l = pm.queryIntentActivities(i, PackageManager.MATCH_DEFAULT_ONLY);
if (l.size()>0) {
return true;
} else {
return false;
}
}
@hkurosawa
hkurosawa / gist:2420936
Created April 19, 2012 13:18
toggle Finder setting to show hidden files
#!/bin/bash
#toggle OSX Finder setting to show the hidden dotfiles
if [ `defaults read com.apple.finder AppleShowAllFiles` -eq 1 ]; then
defaults write com.apple.finder AppleShowAllFiles -bool NO;
else
defaults write com.apple.finder AppleShowAllFiles -bool YES;
fi
killall Finder;
@hkurosawa
hkurosawa / gist:3383994
Created August 18, 2012 02:29
automator script to install apk
ADB_PATH=PATH_TO_ADB
for f in "$@"
do
$ADB_PATH install -r "$f"
done
@hkurosawa
hkurosawa / .zshrc
Created November 16, 2012 11:22
my .zshrc file
autoload -U compinit
autoload colors
compinit
colors
PS1="%{${fg[green]}%}${USER}@${HOST%%.*}:%~ [%D{%y-%m-%d %H:%m:%S}]%{${reset_color}%}
[%!]%(!.#.$) "
PATH=$PATH:/usr/local/bin/
alias ls="ls -G"
@hkurosawa
hkurosawa / gist:7593622
Last active December 29, 2015 01:29
# searches launchd.plist files from launchd directories
#!/bin/bash
# searches launchd.plist files from launchd directories
grep `launchctl list | grep $1 | cut -f 3` ~/Library/LaunchAgents/* /Library/LaunchAgents/* /Library/LaunchDaemons/* /System/Library/LaunchAgents/* /System/Library/LaunchDaemons/* | cut -d ':' -f 1 | uniq
@hkurosawa
hkurosawa / database.php
Last active August 29, 2015 14:00
CakePHP 2.x database.php file to switch between database configuration settings based on file existence under app/Config directory
<?php
// CakePHP 2.x database.php file to switch between database configuration settings based on file existence under app/Config directory
/**
* This is core configuration file.
*
* Use it to configure core behaviour of Cake.
*
* PHP 5
*

#Platforms

  • 2.3.x Gingerbread
  • 4.0.x Ice Cream Sandwich
  • 4.1.x/4.2.x/4.3.x Jelly Bean
  • 4.4.x Kitkat
  • 4.5.x "L"

#Screen Sizes

  • "xlarge" screens are at least 960dp x 720dp
  • "large" screens are at least 640dp x 480dp
@hkurosawa
hkurosawa / gist:54c3df54f1007d6709dd
Last active August 29, 2015 14:04
Windowsに入れるツールのメモ - 思い出したら書く