Skip to content

Instantly share code, notes, and snippets.

View sonique6784's full-sized avatar

sonique6784

View GitHub Profile
@sonique6784
sonique6784 / askgemini.py
Created February 15, 2024 09:37
A minimalist Gemini implementation for Terminal
#
# A minimalist Gemini implementation for Terminal
# Ask Gemini from the command line.
#
import sys
import os
import pathlib
import textwrap
import google.generativeai as genai
@sonique6784
sonique6784 / install.sh
Last active December 14, 2023 10:53
Install and Configure macOS
# Install homebrew - package manager
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# add home brew to the PATH
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> ~/.zprofile
# Oh-my-ssh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# Add cask for unstable version (alpha, beta, nighly)
/* Copyright 2023 Cedric Ferry.
SPDX-License-Identifier: Apache-2.0 */
class MainActivity : ComponentActivity() {
// activity top level interception of the keyboard events
override fun onKeyUp(keyCode: Int, event: KeyEvent?): Boolean {
val ctrl_w = KeyShortcut(KeyEvent.KEYCODE_W, ctrl = true)
val ctrl_r = KeyShortcut(KeyEvent.KEYCODE_R, ctrl = true)
@sonique6784
sonique6784 / GCoreAPIKeyLogin.sh
Last active July 14, 2023 23:35
Gcore labs authentication with API Permanent Token
#!/bin/bash
# Copyright 2023 Cedric Ferry.
# SPDX-License-Identifier: Apache-2.0
# Gcore labs authentication with API Permanent Token
# Make sure you set "APIKey" in the Authorization header
# Get your {TOKEN} here: https://accounts.gcore.com/profile/api-tokens
# Get your {id} here: https://cdn.gcore.com/resources/list
/**
* immersiveExperience for Android
* set your app into immersive mode hidding navigation and status bar
* call this function in Activity#onCreate
*/
private fun immersiveExperience() {
val windowInsetsController =
WindowCompat.getInsetsController(window, window.decorView)
// Configure the behavior of the hidden system bars.
windowInsetsController.systemBarsBehavior =
/* Copyright 2023 Cedric Ferry.
SPDX-License-Identifier: Apache-2.0 */
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.gestures.detectDragGestures
import androidx.compose.foundation.layout.Box
/* Copyright 2023 Cedric Ferry.
SPDX-License-Identifier: Apache-2.0 */
import android.view.Window
import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
@sonique6784
sonique6784 / vimrc.vim
Created February 21, 2023 23:06
vimrc
set backspace=2 " allow backspacing over everything in insert mode
set history=50 " keep 50 lines of command line history
set ignorecase " search commands are case-insensitive
set incsearch " while typing a search command, show matches incrementally
" instead of waiting for you to press enter
set ruler " show the cursor position all the time
set viminfo='20,\"50 " read/write a .viminfo file, don't store more than 50 lines of registers
set encoding=utf8 " non-ascii characters are encoded with UTF-8 by default
set formatoptions=croq " c=autowrap comments, r=continue comment on <enter>,
@sonique6784
sonique6784 / Collections.kt
Last active February 16, 2023 21:37
kotlin findLastIndex() extension function
// https://github.com/JetBrains/kotlin/blob/master/libraries/stdlib/src/kotlin/collections/Collections.kt
/**
* Returns the index of the last item in the list that match predicate
* @param predicate function returning boolean for matching element.
*
* @return the index of the last element found
* otherwise returns -1
*/
public inline fun <T> List<T>.findLastIndex(predicate: (T) -> Boolean): Int {
@sonique6784
sonique6784 / ComposeIndicationAndHoverable.kt
Last active June 22, 2023 21:28
This show how to implements Indication and Hoverable on Compose. This is great to add Mouse and Stylus support in apps, such as hover state, focus state...
/* Copyright 2023 Google.
SPDX-License-Identifier: Apache-2.0 */
@Composable
fun hoverableHighlightAndPointer() {
val highlightIndication: Indication = remember {
HighlightIndication()
}
val interactionSource = MutableInteractionSource()