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 / sweet-captcha.php
Created July 15, 2012 18:19
Sweet Captcha Breaker
<?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 December 11, 2015 10:38
Adding reverse numbers. Solution for the task from ACM Central European Programming Contest, Prague 1998 http://www.spoj.pl/problems/ADDREV/
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 December 11, 2015 10:58
Fixing bug with disappearing map overlay after zoom in Android.
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 January 28, 2013 01:57
Simple code snippet, which show how to convert binary number into decimal number very easily in 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;
<?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" />
TextView txt = (TextView) findViewById(R.id.custom_font);
Typeface font = Typeface.createFromAsset(getAssets(), "Custom_Font.ttf");
txt.setTypeface(font);
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();
<?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" />
@InjectResource(R.drawable.actionbar_custom_background)
private Drawable actionBarCustomBackground;
public void onCreate() {
getSupportActionBar().setBackgroundDrawable(actionBarCustomBackground);
}
@pwittchen
pwittchen / endlessScroll.java
Last active December 12, 2015 09:58
Code Snippet responsible for Endless Scroll View in Android ListView.
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