Skip to content

Instantly share code, notes, and snippets.

View bruce3x's full-sized avatar
🎯
Focusing

bruce3x bruce3x

🎯
Focusing
View GitHub Profile
""""""""""""""""""""""
" Leader
""""""""""""""""""""""
" let mapleader=,
" can't set leaders in Obsidian vim, so the key just has to be used consistently.
" However, it needs to be unmapped, to not trigger default behavior: https://github.com/esm7/obsidian-vimrc-support#some-help-with-binding-space-chords-doom-and-spacemacs-fans
unmap ,
" map ; to : in normal mode, so that I don’t rely on the shift key
" nmap ; :
@cedrickring
cedrickring / ColoredShadow.kt
Last active April 18, 2024 10:29
Draw a colored shadow in Android Jetpack Compose
/*
Copyright 2020 Cedric Kring.
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,
@bruce3x
bruce3x / README.md
Last active August 31, 2022 07:01
美团技术博客 404 页面小彩蛋 🥚

彩蛋娱乐 🎊

Usage

  1. 新建 Chrome 书签,地址栏填入以下代码
javascript:const row=32,col=60,wallWidth=1,padding=1,boxSize=25,wallColor=[233,84,32,255];function index2Pixel(t){return padding+t*(boxSize+wallWidth)/2}function isWall(t,e,n){const o=index2Pixel(e),l=index2Pixel(n),a=(t,e,n)=>{const o=4*(e*t.width+n);return t.data[o]==wallColor[0]&&t.data[o+1]==wallColor[1]&&t.data[o+2]==wallColor[2]&&t.data[o+3]==wallColor[3]};return a(t,o,l)||a(t,o-1,l)||a(t,o+1,l)||a(t,o,l-1)||a(t,o,l+1)}function binaryMap(t){const e=[];for(let n=0;n<2*row+1;n++){const o=[];for(let e=0;e<2*col+1;e++)o.push(isWall(t,n,e)?1:0);e.push(o)}return e}function logMap(t){let e="";for(let n=0;n<t.length;n++){for(let o=0;o<t[n].length;o++)e+=t[n][o];e+="|||\n"}console.log(e)}function findPath(t,e,n){const o=[],l=(e,a)=>!(e<0||e>=t.length||a<0||a>=t[e].length)&&(0==t[e][a]&&(o.push([e,a]),t[e][a]=-1,e==n[0]&&a==n[1]||(!!(l(e-1,a)||l(e+1,a)||l(e,a-1)||l(e,a+1))||void o.splice(o.length-1,1))));return l(e[0],e[1]),o}function drawPath(t,e){t.lineWidth=1
@Karn
Karn / LogController.kt
Last active October 18, 2023 14:59
An example implementation of a process to write logs to disk asynchronously using RxJava
typealias LogElement = Triple<String, Int, String?>
object LogController {
private var flush = BehaviorSubject.create<Long>()
private var flushCompleted = BehaviorSubject.create<Long>()
private var LOG_LEVELS = arrayOf("", "", "VERBOSE",
"DEBUG",
"INFO",
import android.content.Context;
import android.support.annotation.NonNull;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.data.DataFetcher;
import com.bumptech.glide.load.model.stream.StreamModelLoader;
@scottdweber
scottdweber / ExpandingCircleAnimationDrawable.java
Created March 22, 2013 02:14
An example showing how to create and use a Drawable that animates.
package com.example.manualanimation;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.view.animation.AnimationUtils;