Monday, April 15, 2024

Android add custom bitmap to Fresco image library cache

fun addCache(key: String, bitmap: Bitmap) {
    // add cache to memory
    val cacheKey = SimpleCacheKey(key)
    val imagePipeline = Fresco.getImagePipeline()
    val closeableBitmap = CloseableStaticBitmap(
        bitmap,
        {
            it.recycle()
        },
        ImmutableQualityInfo.FULL_QUALITY,
        0, 0
    )

    imagePipeline.bitmapMemoryCache.cache(cacheKey, CloseableReference.of(closeableBitmap))

    // add cache to disk
    val stream = ByteArrayOutputStream()
    bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream)
    val byteArray = stream.toByteArray()
    Fresco.getImagePipelineFactory().mainFileCache.insert(cacheKey) { outputStream ->
        outputStream.write(byteArray)
    }
}
 

Tuesday, December 3, 2019

Node.js sequelize MySQL JSON function 사용하기

select * from actionlog where JSON_EXTRACT(action, '$name')='reward'

const actionLogs: ActionLog[] = await ActionLog.findAll({
    where: Sequelize.where(
        Sequelize.fn('JSON_EXTRACT',
            Sequelize.col('action'),
            '$.name'),
        'reward')
})

Tuesday, October 8, 2019

MariaDB /usr/local/etc/my.cnf.d No such file or directory


$ mysql.server start
/usr/local/Cellar/mariadb/10.3.10/bin/my_print_defaults: Can't read dir of '/usr/local/etc/my.cnf.d' (Errcode: 2 "No such file or directory")
Fatal error in defaults handling. Program aborted
Starting MariaDB
./usr/local/Cellar/mariadb/10.3.10/bin/my_print_defaults: Can't read dir of '/usr/local/etc/my.cnf.d' (Errcode: 2 "No such file or directory")
Fatal error in defaults handling. Program aborted
/usr/local/Cellar/mariadb/10.3.10/bin/my_print_defaults: Can't read dir of '/usr/local/etc/my.cnf.d' (Errcode: 2 "No such file or directory")
Fatal error in defaults handling. Program aborted
191008 10:52:51 mysqld_safe Logging to '/usr/local/var/mysql/namjungsoo-MacBook-Pro.local.err'.
191008 10:52:51 mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
ERROR!
해결 방법: 아래의 명령을 통해서 폴더를 만들어준다.
mkdir /usr/local/etc/my.cnf.d