Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View pwittchen's full-sized avatar
🎯
Focusing

Piotr Wittchen pwittchen

🎯
Focusing
View GitHub Profile
@pwittchen
pwittchen / searchString.java
Created March 30, 2014 15:56
Implementation of Knuth-Morris-Pratt (KMP) algorithm in Java for searching occurences of a specific word in a given string.
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)) {
public interface SampleView {
void displayData(String data);
}
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);
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 June 4, 2014 20:36
How to update synced fork
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:
@pwittchen
pwittchen / ubuntu-boot-error
Created August 17, 2014 19:37
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.
# /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
# /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
@Override
protected void onResume() {
super.onResume();
bus.register(this);
networkEvents.register();
}
@Override
protected void onPause() {
super.onPause();
Bus bus = new Bus();
NetworkEvents networkEvents = new NetworkEvents(this, bus);