Skip to content

Instantly share code, notes, and snippets.

View yamanetoshi's full-sized avatar

YAMANE Toshiaki yamanetoshi

View GitHub Profile
@yamanetoshi
yamanetoshi / IntentIntegratorExample.java
Created August 27, 2015 06:09
IntentIntegrator (ZXing) Example
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn = (Button)findViewById(R.id.button);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// new IntentIntegrator(MainActivity.this).initiateScan(IntentIntegrator.ONE_D_CODE_TYPES);
@yamanetoshi
yamanetoshi / HelloWorldEspressoTest.java
Created August 27, 2015 07:53
Espresso Hello World
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
@yamanetoshi
yamanetoshi / gist:10235370
Last active August 29, 2015 13:58
Custom DialogFragment in Preferences
public static class MyPasswordInputDialog extends DialogFragment {
private SharedPreferences mPref;
private EditText mPasswd1;
private EditText mPasswd2;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
mPref = PreferenceManager.getDefaultSharedPreferences(MyPasswordInputDialog.this.getActivity());
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
@yamanetoshi
yamanetoshi / gist:10247722
Last active August 29, 2015 13:58
Rakefile of FirstStepReVIEW
require 'fileutils'
require 'rake/clean'
def use_bundler()
if system("bundle > /dev/null 2>&1")
"bundle exec "
else
""
end
end
# Makefile - build script */
# build environment
PREFIX ?= /usr/local/cross/rpi/arm-unknown-eabi
ARMGNU ?= $(PREFIX)/bin/arm-unknown-eabi
# source files
SOURCES_ASM := $(wildcard *.S)
SOURCES_C := $(wildcard *.c)
@yamanetoshi
yamanetoshi / gist:11032608
Created April 18, 2014 08:55
Mock of Fog::Compute[:cloudstack] | extract template requests
class Mock
def extract_template(options={})
Fog.credentials[:cloudstack_zone_id] = 1105
template_id = options['id']
template_mode = options['mode']
zoneid = self.data[:zones].keys[0]
zone = self.data[:zones][zoneid]
@yamanetoshi
yamanetoshi / gist:11032745
Created April 18, 2014 08:59
extract_template_test.rb (Fog::Compute[:clooudstack])
Shindo.tests('Fog::Compute[:cloudstack] | extract template requests', ['cloudstack']) do
@extract_template_format = {
'extracttemplateresponse' => {
'jobid' => Integer }}
@queary_async_job_result_format = {
'queryasyncjobresultresponse' => {
'jobid' => Integer,
'jobstatus' => Integer,
@yamanetoshi
yamanetoshi / gist:11105171
Created April 20, 2014 04:38
main function
/* main.c - the entry point for the kernel */
#include <stdint.h>
#include "rpi_lib/rpi.h"
#define UNUSED(x) (void)(x)
// kernel main function, it all begins here
void kernel_main(uint32_t r0, uint32_t r1, uint32_t atags) {
init_gpio();
@yamanetoshi
yamanetoshi / gist:11282290
Created April 25, 2014 08:38
init_gpio function
void init_gpio(void){
int i;
// pullup all
*GPPUD = 0x02;
// wait 150 cycle
for(i=0;i<150;i++){
// nop
asm("mov r0,r0");
}
*GPPUDCLK0 = 0xffffffff;
@yamanetoshi
yamanetoshi / gist:11282860
Created April 25, 2014 09:02
initialize JTAG register in boot.S
// initialize gpio
bl init_gpio
// pinMode(22 ,ALT4)
ldr r3, .L2
ldr r2, .L2
ldr r2, [r2]
orr r2, r2, #192
str r2, [r3]