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
open System | |
open System.Text | |
open System.IO | |
open System.Diagnostics | |
let newProcess = new Process() | |
newProcess.StartInfo.FileName <- "cmd.exe" | |
newProcess.StartInfo.CreateNoWindow <- true | |
newProcess.StartInfo.UseShellExecute <- false | |
newProcess.StartInfo.RedirectStandardInput <- true |
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
let prime () = | |
let infinity = Seq.initInfinite (fun i -> i + 1) |> Seq.filter (fun n -> n >= 2) |> Seq.cache | |
let rec inner (nums: seq<int>) = seq { | |
let i = Seq.item 0 nums | |
yield i | |
let next = nums |> Seq.filter (fun n -> n % i <> 0) |> inner | |
yield! next | |
} |
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
import java.io.Writer; | |
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.Map.Entry; | |
import org.apache.commons.lang3.StringUtils; | |
import com.thoughtworks.xstream.XStream; | |
import com.thoughtworks.xstream.converters.Converter; |
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
/// <summary> | |
/// by fairjm. | |
/// 2016/02/19 | |
/// </summary> | |
class Program | |
{ | |
[DllImport("user32.dll")] | |
static extern IntPtr GetForegroundWindow(); | |
[DllImport("user32.dll")] |
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
open MySql.Data.MySqlClient | |
open FSharp.Interop.Dynamic | |
open Dapper | |
open System | |
open System.Dynamic | |
type GList<'a> = System.Collections.Generic.List<'a> | |
type Ask() = | |
member val AskId = 0 with get,set |
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
open System.Net.Http | |
open System.Net.Mime | |
open System.Text | |
///get fileName by ContentDisposition or random file name if null | |
let getFileName (msg: HttpResponseMessage) = | |
let value = Option.ofObj msg.Content.Headers.ContentDisposition | |
let result = | |
value | |
|> Option.map (fun e -> e.FileName) |
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
package com.cc.imageio.controller; | |
import java.awt.AlphaComposite; | |
import java.awt.Color; | |
import java.awt.Font; | |
import java.awt.Graphics2D; | |
import java.awt.Image; | |
import java.awt.image.BufferedImage; | |
import java.io.ByteArrayOutputStream; | |
import java.io.File; |
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
import re | |
code = """ | |
`name` varchar(10) DEFAULT NULL', | |
`age` int NOT NULL DEFAULT '' | |
""" | |
def parse_field_name(s): | |
return re.sub(r"_(.)", lambda x: x.group(1).upper(), s.replace("`","")) | |
def parse_field_type(t): |
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
camelcase = fn a -> Regex.replace(~r/_([a-z]+)/,a, fn _,<<w::utf8, b::binary>> -> String.upcase(<<w>>) <> b end) end | |
upcaseFirst = fn | |
"" -> "" | |
<<a::utf8, b::binary>> -> String.upcase(<<a>>) <> b | |
end | |
# md5 see https://gist.github.com/10nin/5713366 | |
def md5(data) do | |
Base.encode16(:erlang.md5(data), case: :lower) |
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
/// https://leetcode.com/problems/two-sum/ | |
impl Solution { | |
fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> { | |
let mut nums2 = nums.clone(); | |
nums2.sort(); | |
let mut begin = 0; | |
let mut end = nums.len() - 1; | |
while begin < end { | |
let r = nums2[begin] + nums2[end]; | |
if r == target { |