如何在Windows Azure上搭建VPN

在azure和windows的firewall上面打开下面端口:

443,500,1701,4500

创建完成后,远程桌面进去,在自动弹出的“Server Management”里面点击“Add roles and features”,一路Next到“Server Roles”,然后勾选Remote Access。

再一路Next到“Role Services”,选择”DirectAccess and VPN(RAS)”、”Routing”。

然后一路Next并慢慢等待安装。安装完成后你会发现还需要配置才可以使用。点open the getting started wizard。选Deploy VPN Only。

然后在本机名称上点击右键,选择“Configure and Enable Routing and Remote Access” 在弹出的向导中选择“Custom configuration” 然后把“VPN access”和“NAT”选上,一路next到底。 最后向导会提示你需要启动服务,点击“Start service”。

这时你的机器名下图标应该是绿色,而不是原来的红色,再右键点,选properties。选security tab,勾选“allow customer ipsec policy for l2tp/IKEv2 connection”, 并且输入一个你自己选的preshared key。在ipv4 tab选static address tool, 范围设置192.168.0.100到192.168.0.255。点ok,点yes。

右键点IpV4下面的NAT,点New Interface,加上Ethenet(第一个)。勾选“Public interface connected to the internet” 和Enable NAT on this interface。

最后运行lusrmgr.msc,双击users,双击你的用户名,在Dail-in tab的Network access permission里面选allow access。点ok。

上面是服务器端,客户端假设是win10,需要设置一个registry key:

On the Windows 10 machine, open the registry and navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PolicyAgent, make a new DWORD 32 bit value, call it AssumeUDPEncapsulationContextOnSendRule, give it a value of 2, then reboot the Windows 10 machine. It should connect just fine.

在windows 10上打开vpn setting,添加一个新的vpn,用windows built in provider,输入一个你选的名字,比如vpn,输入服务器地址,选vpn type:L2tp/IPSec with Pre-shared key. 然后输入之前你选的pre-shared key,输入用户名和密码,save。然后就可以登陆了。



喜马拉雅下载后处理方法

如果你从pc端下载的,它会有一个json文件。可以用这个powershell脚本帮你改名字:
(Get-Content -Path 18149301list.json -Encoding UTF8).Replace(“””playtimes”””,”””aaa”””) | ConvertFrom-Json|%{$_.trackId}| %{$i=1}{Move-Item (“.\18149301\”+$_+”.m4a”) -Destination (“s”+$i.ToString(“0000″)+”.mp3″); $i=$i+1} {}
只需要把18149301list.json和\18149301\换成相对应的数字就好。改好就能播放。这个方法只适合免费下载的。有写付费下载的东西改名字后不能播放。

如果你是手机端下载的。名字是乱的,可以根据下载时间改名字,注意下载的时候必须是按顺序下载的:
$count = 1; Get-ChildItem -file| Sort-Object LastWriteTime| %{$newName = ‘{0}{1:0000}{2}’ -f ‘m’, $count, $_.extension; Rename-Item $_ -NewName $newName; $count++}
然后需要用tool解码。

如果想加速听的朋友可以用下面命令处理mp3,先取下载ffmpeg
FOR %i in (*.mp3) DO f:\tools\ffmpeg\bin\ffmpeg.exe -i “%~fi” -af atempo=1.73 -ab 44k %~dpi\%~ni(fast)%~xi”

dental

today my sister and I went to a dental appointment to clean our teeth. l was up first. When I first got in the dental chair the dentist gave me sunglasses that were so big that even my dad could were them. when my turn was over it was my sister’s turn.I thought that my sister was not going to cry but she did. I thought that she wasn’t going to cry because I told her about the balls that you could pick at the end.Anyway, when we were done picking the balls we went to QFC then we went home to bake muffins

YUM!                                                                                                                   YUM!

Really!

Today I was asking my dad to play with me. I said daddy play with me. But he said Sophie can you write in your dairy? then I said DADDY!! Then he said if you write in your dairy I will let you type it on your mom’s keyboard REALLY!! Then I rushed to get started.

snow!

today i was looking out the window . suddently i spang up it’s snowing mommy! it’s snowing daddy! i told them . then i rushed to the window it is snowing bigger! i said.i ran to get them. but when i got there it was so small that you could hardly see it. oh! I said and I walked to write in diary. But when I looked again it was snowing so big.that I could not wait to go to play.

The Skyline Problem

public class Solution {
    public static class Line implements Comparable<Line> {
        public int index;
        public int height;
        public boolean isStart;

        @Override
        public int compareTo(Line arg0) {
            if (index != arg0.index)
                return index - arg0.index;
            return (arg0.isStart?arg0.height:-arg0.height)-(isStart?height:-height);

        }
    }
    public List<int[]> getSkyline(int[][] buildings) {
        List<int[]> result = new ArrayList<int[]>();
        if (buildings == null || buildings.length == 0)
            return result;
        Line[] l = new Line[buildings.length * 2];
        for (int i = 0; i < buildings.length; i++) {
            l[i * 2] = new Line();
            l[i * 2].index = buildings[i][0];
            l[i * 2].height = buildings[i][2];
            l[i * 2].isStart = true;
            l[i * 2 + 1] = new Line();
            l[i * 2 + 1].index = buildings[i][1];
            l[i * 2 + 1].height = buildings[i][2];
            l[i * 2 + 1].isStart = false;
        }
        Arrays.sort(l);
        PriorityQueue<Integer> pq = new PriorityQueue<Integer>(Collections.reverseOrder());
        int height = 0;
        for (Line line : l) {
            if (line.isStart)
                pq.add(line.height);
            else
                pq.remove(line.height);
            int newH = pq.peek() == null ? 0 : pq.peek();
            if (newH != height) {
                height = newH;
                int[] re = new int[2];
                re[0] = line.index;
                re[1] = height;
                result.add(re);
            }
        }
        return result;
    }
}

Palindrome Linked List

public class Solution {
    public boolean isPalindrome(ListNode head) {
         if(head==null||head.next==null)return true;
        ListNode newhead=head;
        int len=0;
        while(newhead!=null){
            newhead=newhead.next;
            len++;
        }
       
        int i=0;
        while(i<len/2){
            ListNode temp=head.next;
            head.next=newhead;
            newhead=head;
            head=temp;
            i++;
        }
        if(len%2==1)head=head.next;
        while(head!=null){
            if(head.val!=newhead.val)return false;
            head=head.next;
            newhead=newhead.next;
        }
        return true;
    }
}

Largest Number

public class Solution {
    public String largestNumber(int[] nums){
        Integer[]in=new Integer[nums.length];
        for (int i = 0; i < nums.length; i++) {
            in[i]=nums[i];
        }
        Arrays.sort(in,new Compare());
        StringBuilder sb = new StringBuilder();
        for (int i = nums.length - 1; i >= 0; i--) {
            sb.append(in[i]);
        }
        if(sb.charAt(0) == '0'){
            return "0";
        }
        return sb.toString();
    }

    public class Compare implements Comparator<Integer> {
        public int compare(Integer arg0, Integer arg1) {
            String s1 = arg0.toString();
            String s2 = arg1.toString() + arg1.toString();
            while (s1.length() < s2.length()) {
                s1 += s1;
            }
            while (s2.length() < s1.length()) {
                s2 += s2;
            }
            return s1.compareTo(s2);
        }

    }
}

Rectangle Area

public class Solution {
    public int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
        int total=(C-A)*(D-B)+(G-E)*(H-F);
        return total-getIntersect(A,C,E,G)*getIntersect(B,D,F,H);
    }
    public int getIntersect(int x1,int x2, int x3, int x4){
        if(x2<x3||x1>x4)return 0;
        return Math.abs(Math.max(x1,x3)-Math.min(x2,x4));
    }
}

Summary Ranges

public class Solution {
    public List<String> summaryRanges(int[] nums) {
        int i=0;
        List<String> result=new ArrayList<String>();
        while(i<nums.length){
            int start =nums[i];
            int end=nums[i];
            while(i<nums.length-1&&nums[i]+1==nums[i+1]){
                end++;
                i++;
            }
            if(start==end){
                result.add(start+"");
            }else{
                result.add(start+"->"+end);
            }
            i++;
        }
        return result;
    }
}