Skip to content

Instantly share code, notes, and snippets.

View xiaoyvr's full-sized avatar

Yu Xiaoqiang xiaoyvr

  • ThoughtWorks
  • Dallas
View GitHub Profile

Hyper-V

Fix the IP address

issue: minishift/minishift#1391

create a virtual switch with name miniNAT, then enable internet sharing for miniNAT in wireless adapter settings.

$env:HYPERV_VIRTUAL_SWITCH="miniNAT" # or something else
$env:MINISHIFT_ENABLE_EXPERIMENTAL="y"
@xiaoyvr
xiaoyvr / docker-cleanup-resources.md
Created November 23, 2017 14:03 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

Manage Node Version in Windows

Require scoop to be installed. Then put these in your $profile, you will get different nodejs for different powershell session.

function Set-LocationWithNodeVersion ($dir){
	Set-Location $dir
	if (Test-Path '.\package.json') {
		$json = Get-Content '.\package.json' | ConvertFrom-Json
		$version = $json.engines.node

First step

find the language settings, reset the hotkey as NotAssigned instead of (`)

things need to do with admin access

  • install docker (need logout, need restart when install hyper-v)
  • uninstall chrome
  • uninstall git, nodejs if they are installed as admin user.

install chrome with user privilege

@xiaoyvr
xiaoyvr / Microsoft.PowerShell_profile.ps1
Last active November 1, 2017 11:49
get windows laptop work without admin priviledge
$path = $env:PATH
$excludes = @('C:\Program Files\nodejs\', 'C:\Program Files\Git\cmd', 'C:\Program Files (x86)\Yarn\bin')
$path = ($path.Split(';') | Where-Object {
-not $excludes.contains($_)
}) -join ';'
$env:PATH = "C:\Program Files (x86)\Microsoft VS Code\bin;$path"
@xiaoyvr
xiaoyvr / CSG-revision.go
Created July 26, 2017 15:25
how couchbase sync gateway generate the document revision id
func createRevID(generation int, parentRevID string, body Body) string {
// This should produce the same results as TouchDB.
digester := md5.New()
digester.Write([]byte{byte(len(parentRevID))})
digester.Write([]byte(parentRevID))
digester.Write(canonicalEncoding(stripSpecialProperties(body)))
return fmt.Sprintf("%d-%x", generation, digester.Sum(nil))
}
@xiaoyvr
xiaoyvr / Either.cs
Created October 24, 2016 08:47 — forked from siliconbrain/Either.cs
Implemetation of Haskell's Either type in C#
/// <summary>
/// Interface definition of Either
/// </summary>
/// <typeparam name="Tl">type of the Left value</typeparam>
/// <typeparam name="Tr">type of the Right value</typeparam>
public interface IEither<out Tl, out Tr>
{
/// <summary>
/// Check the type of the value held and invoke the matching handler function
/// </summary>
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using System.ComponentModel;
using System.Threading;
namespace testdynamic
{
/// <summary>
@xiaoyvr
xiaoyvr / ed2k-pp
Created December 9, 2014 16:39
extract ed2k links from pp
Array.join($('a[data-href^="ed2k"]').map(function(){return $(this).attr('data-href')}), '\n');
require 'formula'
class Solfege < Formula
homepage 'http://www.solfege.org/'
url 'http://ftpmirror.gnu.org/solfege/solfege-3.22.2.tar.xz'
mirror 'http://ftp.gnu.org/gnu/solfege/solfege-3.22.2.tar.xz'
sha1 '060cf7975e17f3d696acd1dfc8676703be7c7ffa'
depends_on "pkg-config" => :build
depends_on "gettext" => :build