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 / sweet-captcha.php
Created Jul 15, 2012
Sweet Captcha Breaker
View sweet-captcha.php
<?php
set_time_limit(0);
$answer_not_found = TRUE;
$counter = 1;
echo("breaking sweet captcha in progress.");
while($answer_not_found)
{
$source = file_get_contents('http://sweetcaptcha.com');
preg_match('/question_[0-9]{1,}\\.png/', $source, $matches_question);
$question_number = explode('_',$matches_question[0]);
@pwittchen
pwittchen / addrev.rb
Last active Dec 11, 2015
Adding reverse numbers. Solution for the task from ACM Central European Programming Contest, Prague 1998 http://www.spoj.pl/problems/ADDREV/
View addrev.rb
def addrev(n)
b = 0
n.split(' ').each do |a|
b+= a.to_s.reverse.to_i
end
return b.to_s.reverse.to_i
end
a = true
i = j = 0
@pwittchen
pwittchen / disablingHWAccelAndroid.java
Last active Dec 11, 2015
Fixing bug with disappearing map overlay after zoom in Android.
View disablingHWAccelAndroid.java
public class ExamplaryMapActivity extends RoboMapActivity {
@InjectView(R.id.mapview)
private MapView mapView;
@Override
protected void onCreate(Bundle bundle) {
enableHWAccel(mapView, false);
}
@TargetApi(11)
@pwittchen
pwittchen / simple_bin2dec_example.c
Created Jan 28, 2013
Simple code snippet, which show how to convert binary number into decimal number very easily in C.
View simple_bin2dec_example.c
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
const char binary[] = "11001";
int decimal = strtol(binary, NULL, 2);
printf("binary = \"%s\", decimal = %d = 0x%02X\n",
binary, decimal, decimal);
return 0;
View android_custom_font.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/custom_font"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is our custom font" />
View custom_android_font.java
TextView txt = (TextView) findViewById(R.id.custom_font);
Typeface font = Typeface.createFromAsset(getAssets(), "Custom_Font.ttf");
txt.setTypeface(font);
View MyEditText.java
public class MyEditText extends EditText{
public MyEditView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
public MyEditView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
View custom_text_view.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.myapp.widget.MyEditText
android:id="@+id/custom_font"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is our custom font" />
View customActionBarBackground.java
@InjectResource(R.drawable.actionbar_custom_background)
private Drawable actionBarCustomBackground;
public void onCreate() {
getSupportActionBar().setBackgroundDrawable(actionBarCustomBackground);
}
@pwittchen
pwittchen / endlessScroll.java
Last active Dec 12, 2015
Code Snippet responsible for Endless Scroll View in Android ListView.
View endlessScroll.java
public class EndlessScrollListener implements OnScrollListener {
private int visibleThreshold = 20;
private int currentPage = 0;
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
}
@Override
You can’t perform that action at this time.