Skip to content

Instantly share code, notes, and snippets.

View codejockie's full-sized avatar

John C. Kennedy codejockie

View GitHub Profile
@codejockie
codejockie / DownloadProgressLiveData.kt
Created March 23, 2024 16:25 — forked from typebrook/DownloadProgressLiveData.kt
Observe Download manager progress using LiveData and Coroutine #android #kotlin #livedata
data class DownloadItem(
val bytesDownloadedSoFar: Long = -1,
val totalSizeBytes: Long = -1,
val status: Int,
val uri: String
)
class DownloadProgressLiveData(private val activity: Activity) :
LiveData<List<DownloadItem>>(),
CoroutineScope {
@codejockie
codejockie / README.md
Created March 6, 2024 18:19 — forked from lopspower/README.md
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@codejockie
codejockie / codility_solutions.txt
Created July 27, 2020 04:50 — forked from lalkmim/codility_solutions.txt
Codility Solutions in JavaScript
Lesson 1 - Iterations
- BinaryGap - https://codility.com/demo/results/trainingU2FQPQ-7Y4/
Lesson 2 - Arrays
- OddOccurrencesInArray - https://codility.com/demo/results/trainingFN5RVT-XQ4/
- CyclicRotation - https://codility.com/demo/results/trainingSH2W5R-RP5/
Lesson 3 - Time Complexity
- FrogJmp - https://codility.com/demo/results/training6KKWUD-BXJ/
- PermMissingElem - https://codility.com/demo/results/training58W4YJ-VHA/
@codejockie
codejockie / Basic_React_Gotchas.md
Created February 26, 2019 21:31 — forked from joeytwiddle/Basic_React_Gotchas.md
Some things we learned in the first few months of using React

Basic React Gotchas

Note: This document was written for someone who already knows React fairly well, because it was initially a list of suggested talking points for a presentation they were planning. Ideally this document should be expanded to include clear examples for the final target audience, which is React beginners.

setState does not apply the update immediately

// Constructor
this.state = { foo: 0 };
@codejockie
codejockie / countChange.js
Created February 23, 2019 23:56 — forked from zestime/countChange.js
JavaScript ver. of Counting coins
function countChange(money, coins) {
if (money == 0) return 1;
if (money < 0 || coins.length == 0) return 0;
return countChange(money - coins[0], coins) + countChange(money, coins.slice(1));
}
@codejockie
codejockie / numberToOrdinal.js
Created February 23, 2019 23:56 — forked from jondwx/numberToOrdinal.js
Number to Ordinal Format
function numberToOrdinal(i) {
var j = i % 10,
k = i % 100;
if (j == 1 && k != 11) {
return i + "st";
}
if (j == 2 && k != 12) {
return i + "nd";
}
if (j == 3 && k != 13) {
@codejockie
codejockie / nodejs_aws_s3_file_upload.js
Created July 18, 2018 17:37 — forked from sarfarazansari/nodejs_aws_s3_file_upload.js
How to upload files to AWS S3 with NodeJS - AWS-SDK? With the help of this library you can upload any kind of file to s3. (NODEJS, AWS-SDK, S3)
/**
* we are going to upload file to s3 via node js by using
* aws-sdk - required
* busboy - required
* uuid - optional - for image renaming purpose
* with this library you can upload any kind of file to s3 via node js.
*/
const AWS = require('aws-sdk');
const UUID = require('uuid/v4');
@codejockie
codejockie / ie-shims.js
Created April 11, 2018 22:33 — forked from djKianoosh/ie-shims.js
IE shims for array indexOf, string startsWith and string trim
// Some common IE shims... indexOf, startsWith, trim
/*
Really? IE8 Doesn't have .indexOf
*/
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
"use strict";
if (this === null) {
throw new TypeError();
@codejockie
codejockie / flatMap.js
Created April 8, 2018 19:09 — forked from samgiles/flatMap.js
Javascript flatMap implementation
// [B](f: (A) ⇒ [B]): [B] ; Although the types in the arrays aren't strict (:
Array.prototype.flatMap = function(lambda) {
return Array.prototype.concat.apply([], this.map(lambda));
};