Wykop.pl – greasemonkey – remove articles below X dig points/remove poststs below X points v.2

Short script for removing articles below X dig points. Works for main and next pagined pages.
You can set own MIN_VALUE.

Below the script.

// ==UserScript==
// @name Wykop.pl - delete articles below X digs
// @namespace *www.wykop.pl/
// @description Deletes articles with dig-points below X points
// @include *www.wykop.pl/*
// @include *www.wykop.pl/strona/*
// @version 2
// @grant none
// ==/UserScript==

var interval = setInterval(function() {
    if(document.readyState === 'complete') {
        removeArticles();
        interval = null;
    }
}, 100);

function removeArticles(){
    var MIN_VALUE = 700;
    var doc = document.getElementsByClassName('link iC');
    for (var i = doc.length - 1; i >= 0; i--)
    {
        var li = doc.item(i);
        //li.textContent
        var digBox = li.getElementsByClassName('diggbox');
        var digBox1 = digBox.item(0);
        var spans = digBox1.getElementsByTagName('span');
        var span = spans.item(0)
        var value = span.innerHTML;

        if (value < MIN_VALUE)
        {
            li.remove();
        }
    }
};

For removing posts, code is below.

// ==UserScript==
// @name Wykop.pl - delete posts below X points
// @namespace *www.wykop.pl/
// @description Deletes posts with points below X points
// @include *wykop.pl/link/*
// @version 2
// @grant none
// ==/UserScript==

var MIN_VALUE = 150;

var doc = document.getElementsByClassName('wblock lcontrast dC');
for (i = doc.length - 1; i >= 0; i--)
{
  var vcs = doc.item(i);
  var vc = vcs.getElementsByClassName('vC');
  var vcv = vc.item(0);
  if(vcv == null)
    continue;
  var sv = vcv.getAttribute('data-vc');
  var rv = parseInt(sv);
  if (rv < MIN_VALUE)
  {
    vcs.remove();
  }
}

Simulating gcm notification from console

In this post I will show only example of using gcm notification broadcasting from console. I assume You have working gcm methods in your project.
You must change also in manifest two things.
1. In gcm receiver You must remove SEND
2. In permission list paste permission to send gcms.

<receiver
android:name="com.example.android.gcm.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND"//<--REMOVE, COPY TO CLIPBOARD
>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="${applicationId}" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>

<!--PERMISSION LIST-->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.c2dm.permission.SEND" />//<--PASTE PERMISSION HERE

Below pattern “how-to” and example.

PATTERN
//adb shell am broadcast -a <Intent-Name> -n <Package>/<Receiver-Name-with-leading-dot> <Extras>

My app needs some params (–es is kind of argument [key-value]).

COMMAND
adb shell am broadcast -a com.google.android.c2dm.intent.RECEIVE -c com.example.android.debug -n com.example.android.google.debug/com.example.android.gcm.GcmBroadcastReceiver --es "key1" "abc" --es "key2" "def"

Wireshark – filter out only results if they are method type POST or GET and not containing in url special word

Example of filtering only that results which have request method as GET or POST and special word is not in url:

(http.request.method == GET or http.request.method == POST) and !http.request.uri contains "css"

Notepad++ with regex, re-using match variables

Here is an simple example how to use regex in notepad++ with reusing selected match variables.

For example we have special code for simulating gcm notifications. We would like to see it in pretty style.
To achieve this we must to move all elements with minus to the new lines. How to do it? Here is the solution.

We have this string:
adb shell am broadcast -a com.google.android.c2dm.intent.RECEIVE -c com.example.android.debug -n com.example.android.google.debug/com.example.android.gcm.GcmBroadcastReceiver --es "aaa" "123" --es "mmm" "bla bla bla" --es "sss" "321" --es "from" "111" --es "type" "yesterday" --es "collapse_key" "do_not_collapse"

By using bellow command in notepad++:

Searching text:

\-[a-z]{0,2}\s

Replace with:

\n($0)

We get the quite pretty result:

adb shell am broadcast
-a com.google.android.c2dm.intent.RECEIVE
-c com.example.android.debug
-n com.example.android.google.debug/com.example.android.gcm.GcmBroadcastReceiver
--es "aaa" "123"
--es "mmm" "bla bla bla"
--es "sss" "321"
--es "from" "111"
--es "type" "yesterday"
--es "collapse_key" "do_not_collapse"

Change time in genymotion emulator – simple java app

I made app in executable jar java file for setting time in genymotion emulator.

Here is simple java code and compiled app for setting time in genymotion app. Below code I showed how the app looks like and also added ready jar app to download.

Code:

public class SetTimeInGenyMotion {
private JTextField textField1;
private JButton getTimeInProperButton;
private JButton setTimeInProperButton;
private JButton getTimeAndSetButton;
private JPanel panel1;
public static final String FORMAT = "YYYYMMDD.HHmmss";

public static void main(String[] args) {
new SetTimeInGenyMotion().doStuff();
}

private void doStuff() {

getTimeInProperButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
textField1.setText(getTime());
}
});

setTimeInProperButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String time = textField1.getText();
setTime(time);
}
});

getTimeAndSetButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String time = getTime();
setTime(time);
textField1.setText(time);
}
});

showWindow();
}

private void showWindow() {
JFrame frame = new JFrame("SetTimeInGenyMotion");
frame.setContentPane(panel1);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setMinimumSize(new Dimension(680, 0));
frame.pack();
frame.setVisible(true);
}

private void setTime(String time) {
try {
String command = "adb shell date -s " + time;

Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(command);
BufferedReader br = new BufferedReader(new InputStreamReader(pr.getErrorStream(), "UTF-8"));
String l = "";

while ((l = br.readLine()) != null) {
System.out.println(l);
}
br.close();

} catch (IOException e1) {
e1.printStackTrace();
}
}

private String getTime() {
//adb shell date -s YYYYMMDD.HHmmss
//http://stackoverflow.com/questions/7094772/how-to-set-android-device-date-time-programmatically

String format = "YYYYMMdd.HHmmss";
Calendar instance = Calendar.getInstance();
String time = getDate(instance.getTimeInMillis(), format);
return time;
}

public static String getDate(long milliSeconds, String dateFormat) {
// Create a DateFormatter object for displaying date in specified format.
SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
// Create a calendar object that will convert the date and time value in milliseconds to date.
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(milliSeconds);
return formatter.format(calendar.getTime());
}
}

Pic:
Zrzut ekranu 2015-06-03 11.58.59

Download:
download