Skip to content

Instantly share code, notes, and snippets.

View bholota's full-sized avatar

Bartłomiej Hołota bholota

View GitHub Profile
@bholota
bholota / gist:4134386
Created November 23, 2012 07:33
CakePHP pagination with component Paginator
//If we will use Paginator component in many actions add it to $components field:
public $components = array('Paginator');
//otherwise do it locally, inside action:
$this->Paginator = $this->Components->load('Paginator');
//optionally we can set conditions etc. (like in finding):
#include <iostream>
#include <fstream>
#include <vector>
#include <regex>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems){
std::stringstream ss(s);
std::string item;
import lightblue
server_sock = lightblue.socket()
server_sock.bind(("", 0))
server_sock.listen(1)
lightblue.advertise("RFCOMM mini server", server_sock, lightblue.RFCOMM)
client_sock, client_info = server_sock.accept()
print "Accepted connection from ", client_info
case MotionEvent.ACTION_UP: {
for (int a = 0; a < MoveList.size(); a++) {
String zxc = MoveList.get(a).toString();
qwe = qwe + zxc + "\n";
}
MyActivity.prevtextview.setText("Prev_angle: " + String.valueOf(mPrevAngle));
MyActivity.currtextview.setText("Curr_angle List: " + String.valueOf(qwe));
@bholota
bholota / gist:7a8c47577a91caf1255d
Created July 8, 2015 12:42
Add crashlyticsUpload tasks dependency on the fly - checking if everything is commited to git
//add it to your build.gradle
//every time when your will call task crashlyticsUploadSomethingSomething it will be called before it
//and it will crash if you have some uncommited changes in your working copy.
//
//I'm using this because I need git sha1 for app versioning in development versions.
task everythingGitCommited << {
def checkChanges = 'git status -uno --porcelain'.execute([], project.rootDir).text.trim()
android {
signingConfigs {
release {
storeFile file(fileConfig['keystore_dir'])
storePassword fileConfig['keystore_password']
keyAlias fileConfig['key_alias']
keyPassword fileConfig['key_password']
}
}
@bholota
bholota / build.gradle
Created August 27, 2015 12:24
gradle task dependency
// Custom tasks
/**
* This test make sure if we have everything committed (or stashed). Allows keep project clean
* and with even small change crashlytics beta upload will have different SHA1.
*/
task testGitWorkingCopy << {
def checkChanges = 'git status -uno --porcelain'.execute([], project.rootDir).text.trim()
@bholota
bholota / MainActivity.java
Created August 31, 2015 14:19
Sample oAuth2 code flow, based on gist service
/**
* Sample oauth2 based on code flow
*/
public class MainActivity extends AppCompatActivity {
private static final String REDIRECT_URL = "http://redirect.com";
private static final String CLIENT_ID = "your_client_id(oauth_key)";
@Override
protected void onCreate(Bundle savedInstanceState) {
@bholota
bholota / sha256combinations.py
Created November 14, 2015 13:48
Generate all combinations for given chars, combination fixed length and print them with sha256 hash
# Simple script that generate all possible string combinations for given lenght
# and generates sha256 hashes for every combination. Combination allow to use
# single char zero or more times.
import hashlib
import itertools
possibleChars = ['a', 'l', 'i', 'n', 's', 'b']
passLen = 7
public static class FadeoutBehavior extends CoordinatorLayout.Behavior<View> {
private int startPos = 0;
private int finalPos = 0;
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
return dependency instanceof AppBarLayout;
}