Skip to content

Instantly share code, notes, and snippets.

View chathudan's full-sized avatar

Chathura Wijesinghe chathudan

View GitHub Profile
@chathudan
chathudan / RecordingActivity.java
Last active January 21, 2024 09:53
Android Audio recording, MediaRecorder example
/**
* @author Chathura Wijesinghe <cdanasiri@gmail.com> on 9/9/15.
*/
public class RecordingActivity extends AppCompatActivity implements View.OnClickListener {
private TextView mTimerTextView;
private Button mCancelButton;
private Button mStopButton;
private MediaRecorder mRecorder;
public static class TrustedSSLSocketFactory extends SSLSocketFactory {
SSLContext sslContext = SSLContext.getInstance("TLS");
public TrustedSSLSocketFactory(KeyStore truststore)
throws NoSuchAlgorithmException, KeyManagementException,
KeyStoreException, UnrecoverableKeyException {
super(truststore);
TrustManager tm = new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] chain,
@chathudan
chathudan / TurnServerInstallationDocumentation.md
Last active April 4, 2020 11:55
Turn Server Installation Documentation

Turn Server Installation Documentation

change the package according to your server

wget http://turnserver.open-sys.org/downloads/v3.2.4.4/turnserver-3.2.4.4-debian-wheezy-ubuntu-
mint-x86-64bits.tar.gz

tar -zxvf turnserver-3.2.4.4-debian-wheezy-ubuntu-mint-x86-64bits.tar.gz

wget http://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
@chathudan
chathudan / GitTips.md
Last active August 29, 2015 14:19
Git Tips

create a new git branch from an old commit

This will create the new branch and check it out.

git checkout -b development a9c146a09505837ec03b

This development the branch without checking it out.

git branch development a9c146a09505837ec03b

Rollback to an old commit using

@chathudan
chathudan / SMSReceiver.java
Last active June 17, 2021 11:32
Android SMS Receive Listener
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
import java.util.ArrayList;
/**
* @@author Chathura Wijesinghe <cdanasiri@gmail.com>
@chathudan
chathudan / AutoResizeTextView.java
Last active June 17, 2021 11:31
Text view that auto adjusts text size to fit within the view. If the text size equals the minimum text size and still does not fit, append with an ellipsis.
import android.content.Context;
import android.text.Layout.Alignment;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.widget.TextView;
/**
* Text view that auto adjusts text size to fit within the view.