Skip to content

Instantly share code, notes, and snippets.

View adoankim's full-sized avatar
🐯

Adoankim adoankim

🐯
View GitHub Profile
@adoankim
adoankim / gen_dates.py
Created January 24, 2022 10:05
Datetime generator between to given dates and a step
from typing import Iterator
from datetime import datetime, timedelta, timezone
def gen_dates(
start_datetime: datetime,
end_datetime: datetime,
delta: timedelta = timedelta(hours = 1)
) -> Iterator[datetime]:
"""
Generate datetimes between two given datetimes with a given delta step
@adoankim
adoankim / batch.py
Last active January 3, 2022 13:53
Python generator to create slices of indices for batching
def batches_generator(list_to_batch_lenght, batch_size):
""" Generate `batch_size` batches of indice slices for a list with len of `list_to_batch_lenght`"""
assert list_to_batch_lenght > 0, "list_to_batch_lenght should be a non-zero positive number"
assert batch_size > 0, "list_to_batch_lenght should be a non-zero positive number"
batches = list_to_batch_lenght // batch_size
for i in range(batches):
start, end = i * batch_size, (i + 1) * batch_size
yield start, end
@adoankim
adoankim / keybase.md
Created June 14, 2020 15:18
keybase.md

Keybase proof

I hereby claim:

  • I am adoankim on github.
  • I am adoankim (https://keybase.io/adoankim) on keybase.
  • I have a public key ASBR0Zfyy3XxbHWRCuZfFTcd6eCSF4UdmH-m1rxdb0tk3Qo

To claim this, I am signing this object:

Verifying my Blockstack ID is secured with the address 1MMRtqzfpDdaG1Hhx56fZGsBL3KW7kbXux https://explorer.blockstack.org/address/1MMRtqzfpDdaG1Hhx56fZGsBL3KW7kbXux
@adoankim
adoankim / AtomicBank.hs
Created April 5, 2019 11:37
Basic concurrency samples with Haskell
#!/usr/bin/env stack
-- stack --resolver lts-12.12 script
import Control.Concurrent.STM
transfer :: TVar Int -> TVar Int -> Int -> STM (Either String (Int, Int))
transfer from to amount = do
balanceA <- readTVar from
balanceB <- readTVar to
@adoankim
adoankim / BlobProvider.java
Last active April 11, 2018 10:13
Support Blob provider on detached Expo apps
/**
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
*
* <p>This source code is licensed under the BSD-style license found in the LICENSE file in the root
* directory of this source tree. An additional grant of patent rights can be found in the PATENTS
* file in the same directory.
*/
package kim.adoan.modules.blob;
import android.content.ContentProvider;
@adoankim
adoankim / redis-server-for-init.d-startup
Created September 12, 2017 15:24 — forked from lsbardel/redis-server-for-init.d-startup
Init.d Redis script for Ubuntu
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
@adoankim
adoankim / unity 2d camera follow
Created November 14, 2015 01:38 — forked from unity3diy/unity 2d camera follow
unity 2d camera follow script, add this script to camera and drag character or your object into it. simple!
using UnityEngine;
using System.Collections;
public class FollowCamera : MonoBehaviour {
public float interpVelocity;
public float minDistance;
public float followDistance;
public GameObject target;
public Vector3 offset;
@adoankim
adoankim / PromiseTest.js
Last active August 29, 2015 14:16
Promise exercise test note
//Log closure function
function getLoggerFunc(error){
var logFunc;
if(error){
logFunc = function(num){ console.error(num); };
}else{
logFunc = function(num){ console.log(num); };
}
return logFunc;
}