Skip to content

Instantly share code, notes, and snippets.

View sabiou's full-sized avatar
📿
La hawla wa la quwwata illa Billah

Farouk Sabiou sabiou

📿
La hawla wa la quwwata illa Billah
View GitHub Profile
@alvincrespo
alvincrespo / application_helper.rb
Created July 21, 2022 11:02
TailwindUI + will_paginate renderer
module ApplicationHelper
def will_paginate(coll_or_options = nil, options = {})
if coll_or_options.is_a? Hash
options = coll_or_options
coll_or_options = nil
end
options = options.merge renderer: TailwindUIPaginationRenderer unless options[:renderer]
super(*[coll_or_options, options].compact)
end
end
@xtexChooser
xtexChooser / Json.kt
Last active May 5, 2023 16:37
JSON type for JetBrains/Exposed
/**
* JSON and JSONB support for github.com/JetBrains/Exposed.
*
* Tested with
* - github.com/pgjdbc/pgjdbc 42.2.x
* - github.com/mysql/mysql-connector-j
* - github.com/h2database/h2database
*
* Based on gist.github.com/qoomon/70bbbedc134fd2a149f1f2450667dc9d
* Thanks for everyone in github.com/JetBrains/Exposed#127
@DRSchlaubi
DRSchlaubi / Arrays.kt
Created February 5, 2022 18:21
Exposed support for arrays
import org.jetbrains.exposed.sql.Column
import org.jetbrains.exposed.sql.ColumnType
import org.jetbrains.exposed.sql.CustomStringFunction
import org.jetbrains.exposed.sql.EqOp
import org.jetbrains.exposed.sql.Expression
import org.jetbrains.exposed.sql.ExpressionWithColumnType
import org.jetbrains.exposed.sql.Table
import org.jetbrains.exposed.sql.statements.api.PreparedStatementApi
import org.jetbrains.exposed.sql.statements.jdbc.JdbcPreparedStatementImpl
import org.jetbrains.exposed.sql.stringLiteral
@manuelvicnt
manuelvicnt / AnAndroidApp.kt
Last active January 1, 2023 17:05
Hilt and AssistedInject working together in Hilt v2.28-alpha times - ViewModel version
// IMPORTANT! READ THIS FIRST
// Assisted Injection doesn't work with @HiltViewModel or @ViewModelInject
// Read more about the issue here: https://github.com/google/dagger/issues/2287
//
//
// AssistedInject and Hilt working together in v2.28-alpha times
// Example of a ViewModel using AssistedInject injected in a Fragment by Hilt
// As AssistedInject isn't part of Dagger yet, we cannot use in
// conjuction with @ViewModelInject
@Sanix-Darker
Sanix-Darker / [PYTHON]PLAGON.py
Created June 6, 2020 01:07
[PYTHON]PLAGON.py
# ____ _ _ ____ ___ _ _
# | _ \| | / \ / ___|/ _ \| \ | |
# | |_) | | / _ \| | _| | | | \| |
# | __/| |___ / ___ \ |_| | |_| | |\ |
# |_| |_____/_/ \_\____|\___/|_| \_|
# --------------------------------------
from os import listdir as os_listdir, path as os_path
# pip install -U scikit-learn
from sklearn.feature_extraction.text import TfidfVectorizer
@gotev
gotev / NavigationBottomBarSectionsStateKeeperWorkaround.kt
Last active June 12, 2023 16:08
JetPack Bottom Bar Navigation with Sections State
package jetpack.navigation.workaround
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.navigation.NavController
import androidx.navigation.ui.setupActionBarWithNavController
import com.google.android.material.bottomnavigation.BottomNavigationView
import java.lang.ref.WeakReference
@mileskrell
mileskrell / build.gradle.kts
Created April 19, 2019 04:26
Example of declaring Android signing configs using Gradle Kotlin DSL
android {
signingConfigs {
getByName("debug") {
keyAlias = "debug"
keyPassword = "my debug key password"
storeFile = file("/home/miles/keystore.jks")
storePassword = "my keystore password"
}
create("release") {
keyAlias = "release"
@ragdroid
ragdroid / IfElse.kt
Created March 2, 2019 14:00
Simplified if-else
infix fun <T>Boolean.then(action : () -> T): T? {
return if (this)
action.invoke()
else null
}
infix fun <T>T?.elze(action: () -> T): T {
return if (this == null)
action.invoke()
@nickbutcher
nickbutcher / ShowbizView.kt
Last active May 24, 2019 03:37
A prototype of an animation I helped out on, see: https://twitter.com/crafty/status/1073612862139064332
/*
* Copyright 2018 Google 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 distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Task
Finish the function numberToOrdinal, which should take a number and return it as a string with the correct ordinal indicator suffix (in English). For example, 1 turns into "1st".
For the purposes of this challenge, you may assume that the function will always be passed a non-negative integer. If the function is given 0 as an argument, it should return '0' (as a string).
To help you get started, here is an excerpt from Wikipedia's page on Ordinal Indicators:
st is used with numbers ending in 1 (e.g. 1st, pronounced first)
nd is used with numbers ending in 2 (e.g. 92nd, pronounced ninety-second)
rd is used with numbers ending in 3 (e.g. 33rd, pronounced thirty-third)