Skip to content

Instantly share code, notes, and snippets.

View GregorBlock's full-sized avatar

Gregor Block GregorBlock

View GitHub Profile
@Carleslc
Carleslc / factorial.kt
Created March 15, 2018 03:56
Factorial in Kotlin
/** If high-performance is needed consider using Guava BigIntegerMath.factorial instead **/
fun Long.factorial(): BigInteger {
fun factorial(start: Long, n: Long): BigInteger {
var i: Long
if (n <= 16) {
var r = BigInteger.valueOf(start)
i = start + 1
while (i < start + n) {
r = r.multiply(BigInteger.valueOf(i))
i++
@Pulimet
Pulimet / AdbCommands
Last active May 21, 2024 06:50
Adb useful commands list
adb help // List all comands
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
@nickbutcher
nickbutcher / 1 search_bar.xml
Last active March 26, 2022 10:03
Demonstrating morphing a search icon into a search field. To do this we use an AnimatedVectorDrawable (https://developer.android.com/reference/android/graphics/drawable/AnimatedVectorDrawable.html) made up of two paths. The first is the search icon (as a single line) the second is the horizontal bar. We then animate the 'trimPathStart' property …
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
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
@craSH
craSH / Password.java
Last active May 9, 2024 21:17
A simple example Java class to safely generate and verify bcrypt password hashes for use in authentication systems.
/**
* Author: Ian Gallagher <igallagher@securityinnovation.com>
*
* This code utilizes jBCrypt, which you need installed to use.
* jBCrypt: http://www.mindrot.org/projects/jBCrypt/
*/
public class Password {
// Define the BCrypt workload to use when generating password hashes. 10-31 is a valid value.
private static int workload = 12;