Skip to content

Instantly share code, notes, and snippets.

@lon9
lon9 / CustomAdapter.java
Last active August 29, 2015 14:14
AndroidでYouTubeのサムネイルをアス比を直して表示する。 ref: http://qiita.com/Rompei/items/46ae14a49b7a383153db
public class CustomAdapter extends ArrayAdapter<VideoItems> {
private LayoutInflater layoutInflater;
private Context context;
public CustomAdapter(Context context, int textViewResourceId, List<VideoItems> objects, RequestQueue queue) {
super(context, textViewResourceId, objects);
layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.context = context;
}
@lon9
lon9 / file0.java
Created May 11, 2015 13:00
Statusbarのサイズ(高さ)を取得する。 ref: http://qiita.com/Rompei/items/4f83ab38f416b60897cb
/**
* Return Statusbar size.
* @param activity Activity
* @return Statusbar size
*/
public static int getStatusBarHeight(Activity activity){
final Rect rect = new Rect();
Window window = activity.getWindow();
window.getDecorView().getWindowVisibleDisplayFrame(rect);
return rect.top;
@lon9
lon9 / getKey.java
Created May 20, 2015 14:16
Concealを使って文字列を暗号化してPreferenceに保存する。 ref: http://qiita.com/Rompei/items/c21c543707510720db2d
public static String getToken(Context context){
SharedPreferences preferences = context.getSharedPreferences(PreferenceValue.PREF_KEY, Context.MODE_PRIVATE);
String accessKey = preferences.getString(PreferenceValue.TOKEN_ACCESS_KEY, null);
String encryptedToken = preferences.getString(PreferenceValue.ENCRYPTED_KEY, null);
byte[] rawEncryptedToken = null;
String rawDecryptedToken = null;
if(encryptedToken!=null&&accessKey!=null) {
rawEncryptedToken = Base64.decode(encryptedToken, Base64.DEFAULT);
Crypto crypto = new Crypto(
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
)
func main() {
#!/bin/sh
#Move any where.
move(){
if [ ! "$#" -eq 1 ]; then
echo "The number of arameters must be 1."
return
fi
case $1 in
android) cd ~/android_workspace ;;
@lon9
lon9 / controllers.js
Last active September 4, 2015 11:26
Angucomplete-altの積みどころ ref: http://qiita.com/Rompei/items/9a69807f7d9fb98aaa8d
$scope.selectedFn = function($item){
$scope.hoges[this.$parent.$index].huga = $item.title;
}
$scope.changedInput = function(huga){
$scope.hoges[this.$parent.$index].huga = huga;
}
@lon9
lon9 / file0.txt
Last active September 5, 2015 12:58
Webページのページングの時に必要になる超簡単なアルゴリズム ref: http://qiita.com/Rompei/items/cc4ca6cffa2fd3c3930a
p:ページナンバー
m:1ページに表示したい項目数
問:sql文を作成したい=>SQLのl:Limitとo:Offsetを求める。また、初期値としてそれぞれl=M,o=0とする。
アルゴリズム:
l=m
o=(p-1)*l
@lon9
lon9 / follow.py
Created September 10, 2015 00:57
Follow all follower and unfollow all follower who is not follow you.
import tweepy
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(OAUTH_TOKEN, OAUTH_SECRET)
api = tweepy.API(auth)
def follow():
followers = api.followers_ids()
friends = api.friends_ids()
@lon9
lon9 / getpass
Last active October 14, 2015 12:44
コンピュータ・ネットワーク、ネットワーク・セキュリティのpdfファイルのパスワードをmacのクリップボードにコピーする
#!/bin/sh
CMDNAME=`basename $0`
CLASS=
if [ $# -ne 1 ]; then
echo "Usage: $CMDNAME <class-bunber>"
exit 1
fi
@lon9
lon9 / addpass
Last active October 14, 2015 12:44
コンピュータ・ネットワーク、ネットワーク・セキュリティのpdfファイルのパスワードをファイルに追加する
#!/bin/sh
CMDNAME=`basename $0`
CLASS=
PASS=
if [ $# -ne 2 ]; then
echo "Usage: $CMDNAME <Class-bunber> <password>"
exit 1
fi