Skip to content

Instantly share code, notes, and snippets.

View kinsleykajiva's full-sized avatar
🏠
Working from home

Kinsley Kajiva kinsleykajiva

🏠
Working from home
  • Africa
  • 16:42 (UTC +02:00)
View GitHub Profile
@kinsleykajiva
kinsleykajiva / OkHttpProgressGlideModule.java
Created January 21, 2017 10:58 — forked from TWiStErRob/OkHttpProgressGlideModule.java
Full POC for showing progress of loading in Glide v3 via OkHttp v2
// TODO add <meta-data android:value="GlideModule" android:name="....OkHttpProgressGlideModule" />
// TODO add <meta-data android:value="GlideModule" tools:node="remove" android:name="com.bumptech.glide.integration.okhttp.OkHttpGlideModule" />
// or not use 'okhttp@aar' in Gradle depdendencies
public class OkHttpProgressGlideModule implements GlideModule {
@Override public void applyOptions(Context context, GlideBuilder builder) { }
@Override public void registerComponents(Context context, Glide glide) {
OkHttpClient client = new OkHttpClient();
client.networkInterceptors().add(createInterceptor(new DispatchingProgressListener()));
glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client));
}
@kinsleykajiva
kinsleykajiva / TimerActivity.java
Created February 23, 2017 18:01 — forked from mjohnsullivan/TimerActivity.java
Example of how to create a long running timer service that survives activity destruction by moving to the foreground, and back to the background when a new activity bind to it.
//
// Copyright 2015 Google Inc. All Rights Reserved.
//
// 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
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/{user}/android-sdks/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
@kinsleykajiva
kinsleykajiva / autocorrrect.py
Created April 18, 2017 12:26 — forked from bgreenlee/autocorrrect.py
Simple ngram autocorrect #python #algorithms
import os.path
import collections
from operator import itemgetter
WORDFILE = '/usr/share/dict/words'
class Autocorrect(object):
"""
Very simplistic implementation of autocorrect using ngrams.
"""
@kinsleykajiva
kinsleykajiva / PrimaryKeyFactory.java
Created April 20, 2017 05:40 — forked from cmelchior/PrimaryKeyFactory.java
Helper class for creating auto increment keys for Realm model classes
/*
* Copyright 2017 Realm Inc.
*
* 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
@kinsleykajiva
kinsleykajiva / RealmAssetLoaderHelperMethods.java
Last active April 20, 2017 06:30 — forked from cmelchior/HelperMethods.java
Load new Realm file from assets when a migration is required
public Realm loadAssetFileOnMigration() {
// TODO Don't re-create this every time
RealmConfiguration config = new RealmConfiguration.Builder()
.schemaVersion(2) // Bumping the schema because new app
.build();
Realm realm;
try {
realm = Realm.getInstance(config);
@kinsleykajiva
kinsleykajiva / scrape_Wikipedia_tables.py
Created May 15, 2017 13:09 — forked from wassname/scrape_Wikipedia_tables.py
Scrape a table from wikipedia using python. Allows for cells spanning multiple rows and/or columns. Outputs csv files for each table
# -*- coding: utf-8 -*-
"""
Scrape a table from wikipedia using python. Allows for cells spanning multiple rows and/or columns. Outputs csv files for
each table
"""
from bs4 import BeautifulSoup
import urllib2
import os
import codecs
import java.security.MessageDigest;
import java.util.Arrays;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
public class TripleDESTest {
@kinsleykajiva
kinsleykajiva / password_pattern.txt
Created September 10, 2017 07:29 — forked from yogonza524/password_pattern.txt
Java pattern for password
((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%-_.]).{6,32})
@kinsleykajiva
kinsleykajiva / JavaFX TC .css
Created September 12, 2017 05:33 — forked from k33ptoo/JavaFX TC .css
Contains basic css for customizing a TableView and Charts.
.table-view .column-header,
.table-view .column-header-background .filler {
-fx-background-color: #6622CC;
}
.table-view .column-header .label{
-fx-text-fill: white;
-fx-font-weight: bold;
-fx-alignment: CENTER_LEFT;
}
.table-view .cell{