This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Convert-Files($source, $dest) { | |
Get-ChildItem -File -Recurse | | |
Where-Object {$_.extension -match "^.(py|js|css|html)$"} | | |
ForEach-Object { | |
Convert-File $_.FullName $source $dest | |
} | |
} | |
function Convert-File($path, $source, $dest) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Open-GitWeb { | |
$r = git remote -v | Select-String -Pattern "(https:\/\/|git@)(?<git>.*)\.git" | |
if ($r.Matches.Length -gt 0) { | |
$t = "https://" + ($r.Matches[0].Groups | | |
Where-Object {$_.Name -eq "git"}).Value.Replace(":", "/") | |
Write-Host "gh: openning ",$t,"..." -ForegroundColor "green" | |
Start-Process $t | |
} | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat base64.txt | base64 --decode > enc.bin | |
openssl aes-256-cbc -d -in enc.bin -out source.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
# @param {integer} n | |
# @return {integer} | |
def countPrimes(self, n): | |
if n < 3: | |
return 0 | |
sieve = [True] * (n / 2) | |
for i in xrange(3, int(n ** 0.5) + 1, 2): | |
if sieve[i / 2]: | |
sieve[i * i / 2::i] = [False] * ((n - i * i - 1) / (2 * i) + 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace TestConsole | |
{ | |
public class Program | |
{ | |
public static void Main(string[] args) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(test). | |
-export([do/0]). | |
do() -> | |
first_word_bin(<<"some words">>). | |
first_word_bin(Bin) -> | |
first_word_bin(ltrim(Bin), <<>>). | |
% <<"some">> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parseURL(url){ | |
var parse_url = /^(?:([A-Za-z]+):(\/{0,3}))?([0-9.\-A-Za-z]+\.[0-9A-Za-z]+)?(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/; | |
var names = ['url', 'scheme', 'slash', 'host', 'port', 'path', 'query', 'hash']; | |
var results = parse_url.exec(url); | |
var that = {}; | |
for (var i = 0, len = names.length; i < len; i += 1) { | |
that[names[i]] = results[i] || ''; | |
} | |
return that; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text; | |
using System.Security.Cryptography; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
Console.WriteLine(Encrypt("123456")); | |
// CE0BFD15059B68D67688884D7A3D3E8C |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(test). | |
-export([do/0]). | |
-define(fuxk(Record, Val), | |
fun() -> | |
list_to_tuple([Record | [get(X,Val) || X <- record_info(fields, Record)]]) | |
end | |
). | |
-record(test, { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import urllib2 | |
from multiprocessing import Pool | |
from multiprocessing.dummy import Pool as ThreadPool | |
def create_urls(): | |
return ["http://www.baidu.com/%s" % i for i in xrange(100)] |
NewerOlder