Skip to content

Instantly share code, notes, and snippets.

Piotr Wittchen pwittchen

Block or report user

Report or block pwittchen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@pwittchen
pwittchen / searchString.java
Created Mar 30, 2014
Implementation of Knuth-Morris-Pratt (KMP) algorithm in Java for searching occurences of a specific word in a given string.
View searchString.java
public class Main {
public static void main(String args[]) {
String givenString = "ABC ABCDAB ABCDABCDABDE";
String searchedString = "ABCDABD";
int givenStringLetterPosition = 0;
int searchedStringLetterPosition = 0;
int foundAt = -1;
while (givenStringLetterPosition < givenString.length()) {
if (givenString.charAt(givenStringLetterPosition) == searchedString.charAt(searchedStringLetterPosition)) {
View SampleView.java
public interface SampleView {
void displayData(String data);
}
View SampleController.java
public class SampleController {
private SampleView view;
public SampleController(SampleView view) {
this.view = view;
}
public void generateData() {
String generatedData = "Exemplary data generated by controller.";
view.displayData(generatedData);
View SampleActivity.java
public class SampleActivity extends Activity implements SampleView {
@InjectView(R.id.sample_textview)
private sampleTextView;
private SampleController controller;
@Override
public displayData(String data) {
sampleTextView.setText(data);
}
@pwittchen
pwittchen / update_synced_fork.txt
Created Jun 4, 2014
How to update synced fork
View update_synced_fork.txt
Original topic: http://stackoverflow.com/questions/7244321/how-to-update-github-forked-repository
In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:
# Add the remote, call it "upstream":
git remote add upstream https://github.com/whoever/whatever.git
# Fetch all the branches of that remote into remote-tracking branches,
# such as upstream/master:
View fstab-version1
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=96889309-5f73-4688-8354-e64cd1bb158f / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
View fstab-version2
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=/dev/sda1 / ext4 errors=remount-ro 0 1
# UUID=96889309-5f73-4688-8354-e64cd1bb158f / ext4 errors=remount-ro 0 1
View ubuntu-boot-error
Gave up waiting for root device. Common problems:
- Boot args (cat /proc/cmdline)
- Check rootdelay= (did the system wait long enough?)
- Check root= (did the system wait for the right device)
- Missing modules (cat /proc/modules; ls /dev)
ALERT! /dev/disk/by-uuid/96889309-5f73-4688-8354-e64cd1bb158f does not exist. Dropping to a shell!
BusyBox v1.21.1 (Ubuntu 1:1.21.0-1ubuntu1) built-in shell (ash)
Enter 'help' for a list of build-in commands.
View initializeBusAndNetworkEvents.java
Bus bus = new Bus();
NetworkEvents networkEvents = new NetworkEvents(this, bus);
View subscribingNetworkEvents.java
@Subscribe
public void connectivityStatusChanged(ConnectivityStatusChangedEvent event) {
// you can perform here any action you want to
// in this example we are displaying toast with Connectivity Status
// and another toast with WiFi info
Toast.makeText(this, event.getConnectivityStatus().toString(), Toast.LENGTH_SHORT).show();
Toast.makeText(this, event.getWifiInfo().toString(), Toast.LENGTH_SHORT).show();
}
You can’t perform that action at this time.