Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Marcin Kitowicz kitek

🏠
Working from home
View GitHub Profile
@kitek
kitek / bitmap.java
Created Jun 21, 2013
How to convert a Drawable to a Bitmap?
View bitmap.java
Bitmap icon = BitmapFactory.decodeResource(context.getResources(),
R.drawable.icon_resource);
@kitek
kitek / compare.txt
Last active Jan 3, 2016
Porównanie string vs bool
View compare.txt
Porównanie string vs bool:
"00" == "0" → bool(true)
"0" == false → bool(true)
ale już:
"00" == false → bool(false)
Porównanie null vs bool vs string:
null == false → bool(true)
@kitek
kitek / compare.txt
Last active Jan 3, 2016
Porównanie int vs string
View compare.txt
0 == "Lorem ipsum" → bool(true)
15 == "15 kwiatów w wazonie" → bool(true)
@kitek
kitek / compare.txt
Last active Jan 3, 2016
Porównanie liczb zapisanych w string'ach.
View compare.txt
"1.00000000000000001" == "0.1e1" → bool(true)
"+1" == "0.1e1" → bool(true)
"1e0" == "0.1e1" → bool(true)
"-0e10" == "0" → bool(true)
"1000" == "0x3e8" → bool(true)
"1234" == " \t\r\n 1234" → bool(true)
View zend_binary_strcmp.c
ZEND_API int zend_binary_strcmp(const char *s1, uint len1, const char *s2, uint len2) /* {{{ */
{
int retval;
if (s1 == s2) {
return 0;
}
retval = memcmp(s1, s2, MIN(len1, len2));
if (!retval) {
return (len1 - len2);
View strcmp.c
ZEND_FUNCTION(strcmp)
{
char *s1, *s2;
int s1_len, s2_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &s1, &s1_len, &s2, &s2_len) == FAILURE) {
return;
}
RETURN_LONG(zend_binary_strcmp(s1, s1_len, s2, s2_len));
View strlen.c
ZEND_FUNCTION(strlen)
{
char *s1;
int s1_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &s1, &s1_len) == FAILURE) {
return;
}
RETVAL_LONG(s1_len);
@kitek
kitek / blad.php
Last active Jan 3, 2016
Wyliczanie błędów względnych i bezwzględny dla uBenchmarka.
View blad.php
<?php
// Dane wejściowe (wklej tutaj kolejne)
$dane = "0.23110198974609
0.23308801651001
0.23321080207825
0.23291993141174";
// Koszt petli + liczba iteracji
@kitek
kitek / list_selector.xml
Last active Jan 3, 2016
Custom ListView selector drawable/list_selector.xml android:listSelector="@drawable/selector"
View list_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" android:constantSize="true">
<item android:state_focused="false" android:state_pressed="false">
<shape android:shape="rectangle">
<solid android:color="@android:color/transparent" />
<stroke android:width="0dp" android:color="@android:color/transparent" />
<padding android:bottom="1dp" android:left="1dp" android:right="1dp" android:top="1dp" />
@kitek
kitek / SquareView.java
Created May 29, 2013
Example of square gridview items
View SquareView.java
package pl.garnek;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
public class SquareView extends ViewGroup {
public SquareView(Context context) {
You can’t perform that action at this time.