Skip to content

Instantly share code, notes, and snippets.

View mingyc's full-sized avatar

Ming-Ying Chung mingyc

  • Tokyo, Japan
  • 20:57 (UTC +09:00)
View GitHub Profile
@mingyc
mingyc / README.md
Last active February 22, 2024 13:12
[WSL] Setting up a local version of VSCode for the Web

[WSL] Setting up a local version of VSCode for the Web

code serve-web is a locally hosted version of Visual Studio Code for the Web (Note that it's different from VSCode Server). To run it within a WSL such that it can be accessed via the Windows host's browser:

  1. Install VSCode on the WSL distrbution via official download page. For example, download and install the .deb files on Debian WSL:
    sudo apt install ./code_xxxx.deb
    
  2. Enable WSL to run crontab on startup [1] (systemd is by default not available in WSL [2]):
@mingyc
mingyc / Virtual Box Host Only Static IP.md
Last active July 18, 2022 15:11 — forked from pjdietz/Virtual Box Host Only Static IP.md
VirtualBox Host-Only Adapter with Static IP

VirtualBox Host-Only Static IP

My typical setup for a development box in VirtualBox uses two NICs. The first uses NAT to allow the box to communicate with the outside world through my host computer’s network connection. (NAT is the default, so shouldn't require any setup.) The second is a "host-only" connection that allows my host and guest to interact.

To create a host-only connection in VirtualBox, start by opening the preferences in VirtualBox. Go to the "Network" tab, and addd a Host-only Network. Modify the host-only network, and disable DHCP. Make a note of the IP address. (Feel free to set the IP address as well, if you like.)

Next, assign this host-only adapter to the virtual machine. Select the VM and press "Settings". Go to the "Network" tab, and select "Adpater 2". Enable the adapter, set it to a "Host-only Adapter", and select the adpater you created above.

Temporary

@mingyc
mingyc / paiza-enkoi-1.py
Last active August 29, 2015 14:10
エンジニアでも恋がしたい! https://paiza.jp/poh/enkoi
# https://paiza.jp/poh/enkoi
from sys import stdin
print sum(map(int, stdin.readlines()[1:]))
原文
ループが書けなくなる(或いは再帰依存症)レベル10
http://d.hatena.ne.jp/yuki_neko_nyan/20090217/1234850409
level 0
不會寫遞迴,也沒辦法用遞迴思考。只覺得用迴圈寫就好了。
level 1
開始學習遞迴,但只要一用遞迴思考就覺得煩。有時還會忘了寫終止條件。覺得實在太麻煩了還是想寫迴圈就好。
@mingyc
mingyc / coscup2012.md
Created August 18, 2012 02:49
COSCUP 2012 Notes

COSCUP 2012

Node.js for Desktop

Desktop

  • Windows Manager
  • Dock
  • System Info
@mingyc
mingyc / sudoku.c
Created March 29, 2012 05:40
A buggy sudoku solver.
#include <stdio.h>
int sudoku[9][9];
int row_count[9][10];
int col_count[9][10];
int box_count[3][3][10];
int check(int r, int c){
if(row_count[r][sudoku[r][c]] != 1)
return 0;
@mingyc
mingyc / property_decorator.py
Created March 22, 2012 11:34
An example of the usage of property() as decorator.
class Circle(object):
def __init__(self, radius):
self._radius = radius
@property
def radius(self):
return self._radius
@radius.setter
def radius(self, value):
self._radius = value
print circle.radius # getter
circle.radius = 10 # setter
del circle.radius # deleter
@mingyc
mingyc / circle_setter.py
Created March 22, 2012 11:22
A simple Circle module with radius setter.
class Circle(object):
def __init__(self, value):
self.radius = None
self.set_radius(value)
def set_radius(self, value):
if value < 0:
raise ValueError('radius must be positive: {0}'.format(value))
self.radius = value
@mingyc
mingyc / circle.py
Created March 22, 2012 11:14
A simple circle module.
class Circle(object):
def __init__(self, radius):
self.radius = radius
circle = Circle(3)
print circle.radius
circle.radius = 10