Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View rwoloszyn's full-sized avatar

Rafal Woloszyn rwoloszyn

View GitHub Profile
@rwoloszyn
rwoloszyn / ContentDesc.java
Created November 4, 2015 14:59
SMS Content description columns
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 March 7, 2016 12:55
Get file extensions in Java using Apache I/O
//If file is compressed uncompress it
if(FilenameUtils.getExtension(file.getAbsolutePath())
.equals("zip")){
logger.debug("file={}, unzipping",
file.getAbsolutePath());
}
@rwoloszyn
rwoloszyn / SomeActivity.java
Created March 8, 2016 22:10
Check if service is running
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;
}
@rwoloszyn
rwoloszyn / AndroidApplication.java
Last active April 6, 2016 13:54
Register broadcastreceiver if debug
/**
* 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 / MonitorActivity.java
Last active April 6, 2016 13:54
Error logger msg
logger.error("msg={}", e.getMessage());
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) {
@rwoloszyn
rwoloszyn / main_single_chart_card.xml
Created April 10, 2016 15:50
Align layouts on the left and right edeges
<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 April 28, 2016 09:56
Remove item from array using underscore.js library
$scope.excludedTrips = _.reject($scope.excludedTrips, function(objArr){
return objArr.id == event.id;
});
@rwoloszyn
rwoloszyn / leaflet-custom-markers.js
Created April 28, 2016 12:57
draw point in some distance betwen two geo points lat/lon
_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 13:52
Create unique list in JS with underscorelibrary
function addFailedTask(taskID){
if(taskID != null){
$scope.failedTaskList.push(taskID);
}
$scope.failedTaskList = _.uniq($scope.failedTaskList);
}