Skip to content

Instantly share code, notes, and snippets.

View elegantcoder's full-sized avatar

Constantine Kim 김현진 elegantcoder

View GitHub Profile
@elegantcoder
elegantcoder / git-subdirectory-tracking.md
Created July 23, 2025 13:50 — forked from tswaters/git-subdirectory-tracking.md
Adding subdirectory of a remote repo to a subdirectory in local repo

This is way more complicated than it should be. The following conditions need to be met :

  1. need to be able to track and merge in upstream changes
  2. don't want remote commit messages in master
  3. only interested in sub-directory of another repo
  4. needs to go in a subdirectory in my repo.

In this particular case, I'm interested in bringing in the 'default' template of jsdoc as a sub-directory in my project so I could potentially make changes to the markup it genereates while also being able to update from upstream if there are changes. Ideally their template should be a separate repo added to jsdoc via a submodule -- this way I could fork it and things would be much easier.... but, it is what it is.

After much struggling with git, subtree and git-subtree, I ended up finding this http://archive.h2ik.co/2011/03/having-fun-with-git-subtree/ -- it basically sets up separate branches from tracking remote, the particular sub-directory, and uses git subtree contrib module to pull it all togther. Following are

@elegantcoder
elegantcoder / README.md
Created January 8, 2025 09:32
camelizeJson

Example:

pbpaste | camelizeJson
@elegantcoder
elegantcoder / esc_to_en.json
Last active January 5, 2025 05:10
vim_escape_to_en.json
{
"title": "Convert to en when ESC",
"//": "orignal author: johngrib(https://github.com/johngrib/simple_vim_guide/blob/master/md/with_korean.md)",
"rules": [
{
"description": "Convert to en when Ctrl+[",
"manipulators": [
{
"type": "basic",
"from": {
@elegantcoder
elegantcoder / git-mv-singularize
Last active October 20, 2023 11:02
Git-mv-singularize
# Get the original name and the singularized name
original_name="$1"
singularized_name=$(singularize "$original_name")
# Compare the original name and the singularized name
if [[ "$original_name" != "$singularized_name" ]]; then
# If they are different, execute git mv
git mv "$original_name" "$singularized_name"
fi
@elegantcoder
elegantcoder / OAuth2Response.type.ts
Created August 14, 2022 15:30
OAuth2Response.type.ts
// Following RFC6749 5.1 Successful Response
export interface OAuth2SuccessfulResponse {
access_token: string;
token_type: string;
expires_in?: number;
refresh_token?: string;
scope?: string;
}
@elegantcoder
elegantcoder / while-in-workflow.yaml
Last active March 4, 2022 14:15
You can use while in workflow `steps.run`
name: using while in Github Workflow
on:
push:
branches:
- '**'
jobs:
test-loop:
timeout-minutes: 2
@elegantcoder
elegantcoder / findFirstAnnotatedArgument.java
Last active September 25, 2020 16:04
[findFirstAnnotatedArgument] #java #springboot #@aspect
@Aspect
public class ControllerJsonStyleAdvice {
private Object findFirstAnnotatedArgument(JoinPoint joinPoint, Class annotation) {
Object[] args = joinPoint.getArgs();
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
for (int i = 0; i < parameterAnnotations.length; i++) {
@elegantcoder
elegantcoder / gist:9b6592c4ea6e9e6464c7a7792b1473a6
Created August 27, 2020 07:45 — forked from rctay/gist:819924
[Java][GAE][Mockito] testing servlet requests/responses
import static org.junit.Assert.*;
import static org.junit.matchers.JUnitMatchers.*; // for non-hamcrest core matchers
import static org.mockito.Mockito.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
@elegantcoder
elegantcoder / PojoFactoryWithDI.java
Last active August 27, 2020 04:41
[PojoFactoryWithDI] #java #spring
import org.springframework.stereotype.Component;
import lombok.RequiredArgsConstructor;
@Component
@RequiredArgsConstructor
class AFactory {
private final AComponent aComponent;
@elegantcoder
elegantcoder / sidekiq.py
Created July 30, 2018 12:27
Sidekiq.py
from redis import Redis
import simplejson
import os
class Sidekiq(object):
"""Dirt simple Sidekiq client in Python. Can be used to create jobs."""
def __init__(self):
host = os.environ['SIDEKIQ_REDIS_HOST']
port = os.environ['SIDEKIQ_REDIS_PORT']
db = os.environ['SIDEKIQ_REDIS_DB']