Skip to content

Instantly share code, notes, and snippets.

View pgreze's full-sized avatar

Pierrick Greze pgreze

View GitHub Profile
@pgreze
pgreze / skyline.py
Created December 15, 2015 23:54
Skyline solutions
#!/usr/bin/env python3
"""Skyline solutions.
See https://pykello.github.io/programming/2015/12/12/haskell-skyline/
Bench with ipython:
%timeit -r 10 skyline.skyline1(skyline.buildings)
10000 loops, best of 10: 19.6 µs per loop
#include "stdio.h"
// Best solution. Complexity: 2N
int solution(int A[], int N) {
if (N == 0) return -1;
if (N == 1) return 0;
int equilibriumIdx = -1;
// Compute sum or array except first element
int rightSum = 0;
package com.example;
public class Iterations {
static int solution_BinaryGap(int N) {
if (N < 2) return 0;
boolean isInGap = false;
int maxGap = 0, currentGap = 0;
for (int i = Integer.SIZE - 1; i >= 0; --i) {
if ((N & (1 << i)) != 0) {
@pgreze
pgreze / ProductLayout.kt
Created April 14, 2017 08:51
A custom FrameLayout with height = height sum of 2 childs
package fr.pgreze.app.ui.product
import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.FrameLayout
import kotlinx.android.synthetic.main.item_product.view.*
class ProductLayout(context: Context, attrs: AttributeSet) : FrameLayout(context, attrs) {
@pgreze
pgreze / japanesepod101-show-vocab.js
Last active May 11, 2017 07:51
Japanese websites scripts
// ==UserScript==
// @name Display pronounciation for all vocabulary
// @namespace https://www.japanesepod101.com/2007/05/24/lower-intermediate-25-tempura-tantrum/
// @version 0.1
// @description Display pronounciation for all vocabulary
// @license GNU Lesser General Public License (LGPL)
// @author pgreze
// @copyright pgreze, GNU Lesser General Public License (LGPL)
// @include https://japanesepod101.com/*
// @include https://www.japanesepod101.com/*
@pgreze
pgreze / sendbird.md
Last active April 27, 2018 06:17
SendBird strong security strategy

1. Create an application (manual)

After login, go to your app Dashboard to discover:

  • APP_ID is your app authentication. Using the same accross all your Android/iOS clients is allowing to access same content.

  • API_TOKEN or in other words your Master API Token. This token is like your Bitcoin private key. NEVER SEND IT TO YOUR CLIENTS!

@pgreze
pgreze / android-kotlin-library.gradle
Last active June 7, 2018 15:44
Kotlin/Android Maven/Bintray publishing
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' // generate Android friendly POM
}
@pgreze
pgreze / CaptorToArgumentMatcher.kt
Last active November 28, 2018 10:05
Replace Mockito Captor by ArgumentMatcher
class CaptorToArgumentMatcher {
@Test
fun captor() {
ArgumentCaptor.forClass(JSONObject::class.java).also { captor ->
verify(tracker).view(eq("screen event"), captor.capture())
assertThat(captor.value.length()).isEqualTo(3)
assertThat(captor.value.get("number")).isEqualTo(12.3)
assertThat(captor.value.get("string")).isEqualTo("value")
@pgreze
pgreze / git-bisect.md
Created May 11, 2019 05:30
Git Bisect How To