Skip to content

Instantly share code, notes, and snippets.

View ytkhs's full-sized avatar
On vacation

ytkhs ytkhs

On vacation
View GitHub Profile
@ytkhs
ytkhs / broadcast_battery_event_to_emulator.sh
Created August 13, 2011 04:37
broadcast battery status changing event to android emulator from terminal
$ adb shell
am broadcast -a android.intent.action.ACTION_POWER_CONNECTED
am broadcast -a android.intent.action.ACTION_POWER_DISCONNECTED
am broadcast -a android.intent.action.BATTERY_OKAY
am broadcast -a android.intent.action.BATTERY_LOW
@ytkhs
ytkhs / send_intent.sh
Created August 16, 2011 09:33
Send Intent to emulator or real device from adb shell
$ adb shell
#sample
am start -a android.intent.action.CALL -d tel://000-0000
am start -a android.intent.action.SEND -d "some message" -t text/plain
am start -a android.intent.action.VIEW -d geo:0,0?q=Tokyo
am start -n com.android.browser/.BrowserActivity
@ytkhs
ytkhs / intent_action_insert_or_edit.java
Created August 29, 2011 08:16
a sample intent action to insert or edit email_adress
Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
intent.putExtra(ContactsContract.Intents.Insert.EMAIL, "[email protected]");
startActivity(intent);
sub _get_day_of_week {
my($y,$m,$d) = @_;
my @wdays = qw(日 月 火 水 木 金 土);
if ($m < 3) {$y—; $m+=12;}
my $w = ($y+int($y/4) - int($y/100) + int($y/400) + int((13*$m+8)/5) + $d) % 7;
@ytkhs
ytkhs / index.html
Created April 27, 2012 02:47
Haml sample with latest jquery
!!! XML UTF-8
!!!
%html{html_attrs('ja')}
%head
%meta{ 'http-equiv' => 'content', :content => 'text/html; charset=utf-8'}
%title test
%script{:src => 'http://code.jquery.com/jquery-latest.js'}
:javascript
$(function(){
alert('hello world!')
@ytkhs
ytkhs / sample.html
Created June 19, 2012 05:50
html template with latest jQuery, twitter bootstrap
<!DOCTYPE html>
<html lang='ja' xml:lang='ja' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='content'>
<title>test</title>
<script src='http://code.jquery.com/jquery-latest.js'></script>
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" media="screen" rel="stylesheet" type="text/css" />
<style type="text/css">
body {
padding-top: 60px;
@ytkhs
ytkhs / deploy.rb
Created October 2, 2012 03:41
sample capistrano for cakephp project
require "bundler/capistrano"
require "capistrano/ext/multistage"
require "capistrano_colors"
require "railsless-deploy"
require "capcake"
set :stages, %w(production staging private)
set :default_stage, "private"
set :use_sudo, false
@ytkhs
ytkhs / default.tpl
Last active October 13, 2015 15:07
Cakephp2.1+ layout template with Twig plugin when use autoescape.(using https://github.com/predominant/TwigView )
{{html.docType('html5')|raw}}
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>{{title_for_layout}} | SITE_NAME</title>
{{html.meta('favicon.ico', '/favicon.ico', {'type':'icon'})|raw}}
<meta name="Keywords" content="KEYWORD_FOR_SITE" />
<meta name="Description" content="DESCRIPTION_FOR_SITE" />
{{_view.fetch('meta')|raw}}
{{_view.fetch('css')|raw}}
@ytkhs
ytkhs / cake_twitterbootstrap_pagination.ctp
Last active December 11, 2015 17:38
cakephp 2.3+ pagination like twitter bootstrap
<div class="pagination pagination-centered">
<ul>
<?php
echo $this->Paginator->prev(
'前へ',
array(
'tag' => 'li',
'disabledTag' => 'a'
),
null,
@ytkhs
ytkhs / edit_extentions.sh
Created June 6, 2013 03:10
拡張子を一括で変更する
# ctp -> tpl の例
$ for nm in *.ctp; do git mv $nm ${nm%.ctp}.tpl; done