Skip to content

Instantly share code, notes, and snippets.

Avatar

Rafal Woloszyn rwoloszyn

View GitHub Profile
@rwoloszyn
rwoloszyn / ContentDesc.java
Created Nov 4, 2015
SMS Content description columns
View ContentDesc.java
Those are values for android 4.4.4 in S3 for Smasung S3.
V/ActivityManager$SmsObserver(17187): .onChange: SMS Send !!! timestamp: 1446649046654
V/ActivityManager$SmsObserver(17187): .onChange: _id and its value: 211
V/ActivityManager$SmsObserver(17187): .onChange: thread_id and its value: 7
V/ActivityManager$SmsObserver(17187): .onChange: address and its value: +48692631872
V/ActivityManager$SmsObserver(17187): .onChange: person and its value: null
V/ActivityManager$SmsObserver(17187): .onChange: date and its value: 1446649046654
V/ActivityManager$SmsObserver(17187): .onChange: date_sent and its value: 1446649022000
V/ActivityManager$SmsObserver(17187): .onChange: protocol and its value: 0
@rwoloszyn
rwoloszyn / JavaIO.java
Created Mar 7, 2016
Get file extensions in Java using Apache I/O
View JavaIO.java
//If file is compressed uncompress it
if(FilenameUtils.getExtension(file.getAbsolutePath())
.equals("zip")){
logger.debug("file={}, unzipping",
file.getAbsolutePath());
}
@rwoloszyn
rwoloszyn / SomeActivity.java
Created Mar 8, 2016
Check if service is running
View SomeActivity.java
private boolean isMyServiceRunning(Class<?> serviceClass) {
logger.debug("serviceClass={}", serviceClass);
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (serviceClass.getName().equals(service.service.getClassName())) {
return true;
}
}
return false;
}
View MonitorActivity.java
private void readLogs() {
logger.debug("Enter");
BufferedReader logReader = null;
try {
String line = null;
File log = getLogFile();
logReader = new BufferedReader(new FileReader(log));
while ((line = logReader.readLine()) != null) {
View MonitorActivity.java
logger.error("msg={}", e.getMessage());
@rwoloszyn
rwoloszyn / AndroidApplication.java
Last active Apr 6, 2016
Register broadcastreceiver if debug
View AndroidApplication.java
/**
* Test broadcast receiver used only for debug
*/
private BroadcastReceiver testTransitStateReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
logger.debug("Entry");
Log.d("SomeReceiver", "testTransitStateReceiver");
if(TEST_ACTION.equals(intent.getAction())){
String extras = intent.getStringExtra("state");
@rwoloszyn
rwoloszyn / main_single_chart_card.xml
Created Apr 10, 2016
Align layouts on the left and right edeges
View main_single_chart_card.xml
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/no_answer_image"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_marginLeft="5dp"
@rwoloszyn
rwoloszyn / controllers.js
Created Apr 28, 2016
Remove item from array using underscore.js library
View controllers.js
$scope.excludedTrips = _.reject($scope.excludedTrips, function(objArr){
return objArr.id == event.id;
});
@rwoloszyn
rwoloszyn / leaflet-custom-markers.js
Created Apr 28, 2016
draw point in some distance betwen two geo points lat/lon
View leaflet-custom-markers.js
_calculateOffset: function(bearing_angle, radius){
//Calculate destination point based on bearing and distance
//http://www.movable-type.co.uk/scripts/latlong.html
var d2r = L.LatLng.DEG_TO_RAD; //simple convert do radians
var r2d= L.LatLng.RAD_TO_DEG; //simple convert to degrees
var radius = radius/1500;
var lat = this._latlng.lat * d2r;
var lng = this._latlng.lng * d2r;
var angle = bearing_angle * d2r;
var R = 6372.795477598;
@rwoloszyn
rwoloszyn / controllers.js
Created May 31, 2016
Create unique list in JS with underscorelibrary
View controllers.js
function addFailedTask(taskID){
if(taskID != null){
$scope.failedTaskList.push(taskID);
}
$scope.failedTaskList = _.uniq($scope.failedTaskList);
}