Skip to content

Instantly share code, notes, and snippets.

@shogonir
shogonir / SelfSample
Created October 3, 2016 13:34
Self type sample code implemented with Scala.
package SelfSample
/**
* Created by shogo on 2016/10/03.
*/
trait MiddleValue {
def middle (list: List[Double]): Double
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.shogonir.android_individual.MainActivity">
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/**
* Created by shogo on 2016/06/04.
*/
public class BookmarkApiCaller extends ApiCaller {
private TextView mTextView;
public BookmarkApiCaller (TextView textView) {
mTextView = textView;
}
@shogonir
shogonir / ApiCaller.java
Created June 4, 2016 03:26
api caller with okhttp
import android.os.Handler;
import java.io.IOException;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
EditText editText = (EditText)findViewById(R.id.edit_text);
String editTextString = editText.getText().toString();
TextView textView = (TextView)findViewById(R.id.text_view);
textView.setText(getResources().getString(R.string.label, editTextString));
EditText editText = (EditText)findViewById(R.id.edit_text);
String editTextString = editText.getText().toString();
TextView textView = (TextView)findViewById(R.id.text_view);
textView.setText("EditText string = " + editTextString);
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class CheckHatenaID {
public static void main (String[] args) {
String hatenaID = "shogonir";
Pattern p = Pattern.compile("[a-zA-Z][a-zA-Z0-9_\\-]{1,30}[a-zA-Z0-9]");
Matcher m = p.matcher(hatenaID);
boolean f = m.matches();
@shogonir
shogonir / test.py
Created September 30, 2015 07:00
import example of Python 2
#! /usr/bin/env python
# -*- coding:utf-8 -*-
import sys
sys.path.append('../')
from Testlib import *
print library_name()
@shogonir
shogonir / Testlib.py
Created September 30, 2015 06:58
import example of Python
def library_name () :
return 'Testlib'