Skip to content

Instantly share code, notes, and snippets.

View WenxiJin's full-sized avatar
🎯
Focusing

Wenxi Jin WenxiJin

🎯
Focusing
  • Sophion Bioscience A/S
  • Denmark
View GitHub Profile
@WenxiJin
WenxiJin / builder_pattern.cpp
Created November 24, 2020 14:46 — forked from niosus/builder_pattern.cpp
An example of builder pattern in c++
#include <stdio.h>
#include <memory>
class BBuilder;
class A {
public:
A() {}
virtual ~A() { fprintf(stderr, "A done.\n"); }
int getA() const { return _a; }
@WenxiJin
WenxiJin / CountDownLatchDemo.java
Created May 13, 2019 11:15
Main thread continues until worker thread finishes
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
public class CountDownLatchDemo {
public static void main(String args[]) throws InterruptedException {
CountDownLatch latch = new CountDownLatch(1);
Worker first = new Worker(10, latch, "1st-Worker");
first.start();
@WenxiJin
WenxiJin / example-subtree-usage.md
Created July 21, 2017 20:28 — forked from kvnsmth/example-subtree-usage.md
A real world usage for git subtrees.

Let's say you have an iOS project, and you want to use some external library, like AFNetworking. How do you integrate it?

With submodules

Add the project to your repo:

git submodule add git@github.com:AFNetworking/AFNetworking.git Vendor/AFNetworking

or something to that effect.

@WenxiJin
WenxiJin / install_global.sh
Last active July 12, 2017 11:21
Install gnu global 6.5.7
#!/usr/bin/env bash
set -e
echo "installing package for gnu global"
sudo apt-get update
@WenxiJin
WenxiJin / cnc.c
Created March 16, 2017 20:41 — forked from scvalex/cnc.c
Mastermind solver in C
#include <stdio.h>
#include <string.h>
int rulled_out[10000 / sizeof(int) + 1];
int num_left;
// Try guess GUESS and mark the entries in RULLED_OUT that match the
// numbers that cannot be the secret (i.e. numbers that compared to
// GUESS are not COMP).
void update_rulled_out(int guess, int comp);
@WenxiJin
WenxiJin / .dir-locals.el
Created November 22, 2016 16:31
Apple swift .dir-locals.el
;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")
((nil
(eval let*
((x (dir-locals-find-file default-directory))
(this-directory (if (listp x) (car x) (file-name-directory x))))
(unless (featurep 'swift-project-settings)
(add-to-list 'load-path
(concat this-directory "utils")
@WenxiJin
WenxiJin / .dir-locals.el
Last active November 22, 2016 16:56
Disable whitespace-mode in java-mode
;; The 'nil' configuration applies to all modes.
((nil . (
(indent-tabs-mode . t)
(tab-width . 4)))
(java-mode . (
(show-trailing-whitespace . nil)
(eval . (global-whitespace-mode 0))))
)
@WenxiJin
WenxiJin / mk-clang_complete.sh
Created November 22, 2016 13:16
Script for generating .clang_complete for qamp-application
#!/usr/bin/env bash
set -e
# absolute path
export WORKSPACE="/home/wjn/workspace"
export PATH=$PATH:/home/wjn/eclipse/gnutools/arm-eabi/bin
# CC='/home/wjn/bin/cc_args.py gcc' CXX='/home/wjn/bin/cc_args.py g++' -B \
make V=1 \
@WenxiJin
WenxiJin / .zshrc
Created September 22, 2016 13:59
Partial .zshrc script for setting tmux pane title on ssh hostname
ssh() {
if [ "$(ps -p $(ps -p $$ -o ppid=) -o comm=)" = "tmux" ]; then
tmux rename-window "$(echo $* | cut -d . -f 1)"
command ssh "$@"
tmux set-window-option automatic-rename "on" 1>/dev/null
else
command ssh "$@"
fi
}
@WenxiJin
WenxiJin / gitconfig.ini
Last active September 1, 2017 09:14 — forked from tdd/gitconfig.ini
Nice, useful global Git configuration
# Put this in your ~/.gitconfig or ~/.config/git/config
# Windows users: "~" is your profile's home directory, e.g. C:\Users\<YourName>
[user]
name = Wenxi Jin
email = jwenxi@gmail.com
[color]
# Enable colors in color-supporting terminals
ui = auto
[alias]
st = status