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
  • 17:44 (UTC +02:00)
View GitHub Profile
@kinsleykajiva
kinsleykajiva / group-objects-by-property.md
Created March 25, 2019 02:32 — forked from JamieMason/group-objects-by-property.md
Group Array of JavaScript Objects by Key or Property Value

Group Array of JavaScript Objects by Key or Property Value

Implementation

const groupBy = key => array =>
  array.reduce((objectsByKeyValue, obj) => {
    const value = obj[key];
    objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
    return objectsByKeyValue;
@kinsleykajiva
kinsleykajiva / Movable JavaFX Window.java
Created September 12, 2017 05:34 — forked from k33ptoo/Movable JavaFX Window.java
Renders a borderless/underdecorated window movable/dragable
/*
* The MIT License
*
* Copyright 2017 keeptoo.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@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{
@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})
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 / 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
@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 / 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 / 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 / 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