Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Marcin Kitowicz kitek

🏠
Working from home
View GitHub Profile
@kitek
kitek / gist:1579117
Created Jan 8, 2012
NodeJS create md5 hash from string
View gist:1579117
var data = "do shash'owania";
var crypto = require('crypto');
crypto.createHash('md5').update(data).digest("hex");
@kitek
kitek / CircleTransform.kt
Last active Apr 29, 2020 — forked from julianshen/CircleTransform.java
CircleTransform for Picasso in Kotlin
View CircleTransform.kt
/*
* Copyright 2014 Julian Shen
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@kitek
kitek / SwipeToDeleteCallback.kt
Created Jan 24, 2018
Example demonstrating how to disable swipe to delete for the particular item.
View SwipeToDeleteCallback.kt
package pl.kitek.rvswipetodelete
import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.support.v4.content.ContextCompat
import android.support.v7.widget.RecyclerView
import android.support.v7.widget.helper.ItemTouchHelper
@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) {
View TriangleShapeView.kt
package your.package.name
import android.content.Context
import android.graphics.*
import android.util.AttributeSet
import android.view.View
class TriangleShapeView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
@kitek
kitek / DbHelper.kt
Created Jun 21, 2016
Kotlin DbHelper
View DbHelper.kt
import android.content.Context
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteOpenHelper
class DbHelper(context: Context) : SQLiteOpenHelper(context, "some.db", null, 1) {
override fun onUpgrade(db: SQLiteDatabase?, oldVersion: Int, newVersion: Int) {
}
@kitek
kitek / disableLayout.php
Last active Jan 3, 2016
ZF disable: view + layout
View disableLayout.php
<?
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
@kitek
kitek / sort.php
Last active Jan 3, 2016
Sortowanie tablicy wielowymiarowej
View sort.php
<?
// Proste sortowanie tablicy wielowymiarowej w obiekcie
// (w tym przypadku sortujemy malejąco po wymiarze 'similar')
class klasa {
public sortuj() {
usort($tablicaDoSortowania, array('klasa','compare'));
}
public function compare($a, $b) {
if ($a['similar'] == $b['similar']) {
@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 / 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