Skip to content

Instantly share code, notes, and snippets.

View ohmrefresh's full-sized avatar
😀

Ohm ohmrefresh

😀
  • Bangkok, Thailand
View GitHub Profile
public Bitmap getScreenshotFromRecyclerView(RecyclerView view) {
RecyclerView.Adapter adapter = view.getAdapter();
Bitmap bigBitmap = null;
if (adapter != null) {
int size = adapter.getItemCount();
int height = 0;
Paint paint = new Paint();
int iHeight = 0;
final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
@ohmrefresh
ohmrefresh / DividerItemDecoration.java
Created February 4, 2016 07:56 — forked from alexfu/DividerItemDecoration.java
An ItemDecoration that draws dividers between items. Pulled from Android support demos.
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@ohmrefresh
ohmrefresh / Readme.md
Created February 4, 2016 05:34 — forked from gabrielemariotti/Readme.md
A SimpleSectionedRecyclerViewAdapter: use this class to realize a simple sectioned `RecyclerView.Adapter`.

You can use this class to realize a simple sectioned RecyclerView.Adapter without changing your code.

The RecyclerView should use a LinearLayoutManager. You can use this code also with the TwoWayView with the ListLayoutManager (https://github.com/lucasr/twoway-view)

This is a porting of the class SimpleSectionedListAdapter provided by Google

Screen

Example:

@ohmrefresh
ohmrefresh / MainActivity.java
Created January 29, 2016 03:17 — forked from noxi515/MainActivity.java
Tab + ChildFragment sample
package jp.noxi.sample;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTabHost;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
@ohmrefresh
ohmrefresh / AttTest
Last active August 29, 2015 14:21
Create ARFF File
import java.io.File;
import weka.core.Attribute;
import weka.core.FastVector;
import weka.core.Instance;
import weka.core.Instances;
import weka.core.converters.ArffSaver;
import weka.filters.Filter;
import weka.filters.unsupervised.instance.NonSparseToSparse;
@ohmrefresh
ohmrefresh / WekaEvaluationAndroid
Last active August 29, 2015 14:21
Weka Evaluation Classify #RandomForest #Android
InputStream is =getResources().openRawResource(R.raw.r4_reference); //arff
BufferedReader datafile = new BufferedReader(new InputStreamReader(is));
try {
Instances m_Training = new Instances(datafile);
m_Training.setClassIndex(m_Training.numAttributes() - 1);
Filter m_Filter = ((Filter)Class.forName("weka.filters.unsupervised.instance.Randomize").newInstance());
m_Filter.setInputFormat(m_Training);
Instances localInstances = Filter.useFilter(m_Training, m_Filter);
Classifier m_Classifier = Classifier.forName("weka.classifiers.trees.RandomForest", null);
m_Classifier.buildClassifier(localInstances);
@ohmrefresh
ohmrefresh / gist:eec95a19e22a6adc9b48
Created January 30, 2015 04:03
Nginx & Laravel
apt-get install nginx php5-fpm php5-cli php5-mcrypt git
mkdir /var/www
mkdir /var/www/laravel
nano /etc/nginx/sites-available/default
------------------------------------------------------------------------
server {
listen 80 default_server;
@ohmrefresh
ohmrefresh / gist:a415dcc7bd1fd38506ca
Created November 10, 2014 03:28
[Solve] unknown architecture armv5
./compile-ffmpeg.sh all
====================
[*] check archs
====================
FF_ALL_ARCHS = armv5 armv7a x86
====================
[*] check env armv5
====================
NDKr10c (64-bit) detected
@ohmrefresh
ohmrefresh / gist:ddd8e2e9f662e6cbf33e
Created October 16, 2014 08:09
Drawable Backgroud Android [exclude Left Border]
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape
android:shape="rectangle">
<stroke android:width="1dp" android:color="#FF000000" />
<solid android:color="#FFFFFF" />
</shape>
</item>
@ohmrefresh
ohmrefresh / gist:5440c598fa95e77bb2f1
Created October 6, 2014 10:50
CSS Max line in DIV
.text {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
line-height: 16px;
max-height: 32px;
-webkit-line-clamp: 2; /* number of lines to show */
-webkit-box-orient: vertical;
}