Skip to content

Instantly share code, notes, and snippets.

View japharr's full-sized avatar
🏠
Working from away

Jelil Adesina japharr

🏠
Working from away
View GitHub Profile
@japharr
japharr / thumbnail.java
Created April 7, 2020 20:51
Creating thumbnail for video, image, folder or other file
private void bind(FileItem item) {
this.item = item;
if (item.isVideo()) {
Bitmap thumbnail = ThumbnailUtils.createVideoThumbnail(
item.path, MediaStore.Video.Thumbnails.MINI_KIND);
image.setImageBitmap(thumbnail);
} else if (item.isImage()) {
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
Bitmap bitmap = BitmapFactory.decodeFile(item.path, bmOptions);
bitmap = Bitmap.createScaledBitmap(bitmap, itemView.getWidth(), itemView.getHeight(), true);
@japharr
japharr / gist:5961f85a4cd1dad6408d3953597a45a1
Created March 16, 2020 18:57
Creating Android Native SearchView in ActionBar
override fun onCreateOptionsMenu(menu: Menu): Boolean {
val searchItem: MenuItem? = menu.findItem(R.id.action_search)
if (searchItem != null) {
searchView = MenuItemCompat.getActionView(searchItem) as SearchView
searchView.setOnCloseListener {
searchView.onActionViewCollapsed()
Log.v("MainActivity", "setOnCloseListener: onClose")
true
}
@japharr
japharr / schema.sql
Created August 18, 2019 04:00 — forked from fernandomantoan/schema.sql
Schema for PostgreSQL to use with JdbcTokenStore (Spring Security OAuth2)
create table oauth_client_details (
client_id VARCHAR(256) PRIMARY KEY,
resource_ids VARCHAR(256),
client_secret VARCHAR(256),
scope VARCHAR(256),
authorized_grant_types VARCHAR(256),
web_server_redirect_uri VARCHAR(256),
authorities VARCHAR(256),
access_token_validity INTEGER,
refresh_token_validity INTEGER,
@japharr
japharr / SecurePreferences.java
Created September 12, 2018 17:05
Android SecurePreferences
/*
* Copyright (C) 2015, Scott Alexander-Bown, Daniel Abraham
*
* 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
@japharr
japharr / detect.java
Created December 6, 2017 00:01
Detect if new install or updated version (Android app)
public static boolean isFirstInstall() {
try {
long firstInstallTime = App.getContext().getPackageManager().getPackageInfo(getPackageName(), 0).firstInstallTime;
long lastUpdateTime = App.getContext().getPackageManager().getPackageInfo(getPackageName(), 0).lastUpdateTime;
return firstInstallTime == lastUpdateTime;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
return false;
}
}
@japharr
japharr / install.txt
Created August 31, 2017 03:22
Install/Upgrade Jhipster
To upgrade/install jhipster
------------------------------
delete the local node_modules in your project folder
do npm i generator-jhipster -g
do npm i generator-jhipster-entity-audit -g
run npm i in the project folder
@japharr
japharr / .kt
Created June 22, 2017 12:10
Displaying Date/Time Picker in Android
//var date: Calendar? = null
fun rescheduleInstallation() {
val currentDate = Calendar.getInstance()
val date = Calendar.getInstance()
DatePickerDialog(this, object : DatePickerDialog.OnDateSetListener {
override fun onDateSet(view: DatePicker, year: Int, monthOfYear: Int, dayOfMonth: Int) {
date?.set(year, monthOfYear, dayOfMonth)
TimePickerDialog(this@InstallationDetailActivity, TimePickerDialog.OnTimeSetListener { view, hourOfDay, minute ->
date?.set(Calendar.HOUR_OF_DAY, hourOfDay)
date?.set(Calendar.MINUTE, minute)
@japharr
japharr / .sql
Created February 7, 2017 15:03
sample
SELECT r.*
FROM region r, vehicleparameters vp, vehicle v
WHERE r.region = vp.REGION_ID and v.id = vp.VEHICLE_ID
@japharr
japharr / .sql
Last active February 7, 2017 14:39
saveit
UPDATE vehicleparameters vp
SET vp.REGION_ID = 71003331 WHERE vp.VEHICLE_ID =
(
SELECT v.ID
FROM vehicle v
WHERE v.registrationno = 'BDG 384 AU'
);
UPDATE vehicleparameters vp
SET vp.REGION_ID = 71003331 WHERE vp.VEHICLE_ID =
@japharr
japharr / .txt
Created January 30, 2017 14:18
Sample
http://197.210.2.132/galooliDevKitService/galooliDevKitService.svc/json/GetDailyInformation?userName=progserver&userHost=mtnn-business&userOrg=zon_mtnn_business&password=sattrak&requestedUnits=1116440&startDate=2017-01-01&endDate=2017-01-16&requestedPropertiesStr=date,unit_id,unit_name,fuel_init,fuel_final