Skip to content

Instantly share code, notes, and snippets.

View zhangyuan's full-sized avatar

Yuan Zhang zhangyuan

  • Xi'an, China
  • 12:46 (UTC +08:00)
View GitHub Profile
ffmpeg -i input.avi -c:v libx264 -crf 19 -preset slow -c:a aac -strict experimental -b:a 192k -ac 2 out.mp4
declare @ids table (id int)
insert into @ids
select [id] as ids from [table_name] where [column_name] is not null
SELECT * FROM [another_table_name] where [id] in (select top 2000 id from @ids)
@zhangyuan
zhangyuan / invoke-request.ps1
Created December 20, 2016 06:21
Send HTTP Request with Credential (HTTP Basic Authentication)
$username = ""
$password = ""
$url = ""
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential ($username, $securePassword)
$stream = Invoke-WebRequest -Uri url -Credential $credential
Write-Host $stream.content
@zhangyuan
zhangyuan / PATTERN
Created December 15, 2016 14:32
logstash configration for Go CD server's go-server.log
GO_SERVER_DATE %{YEAR}-%{MONTHNUM}-%{MONTHDAY} %{HOUR}:%{MINUTE}:%{SECOND},%{INT}
GO_SERVER %{GO_SERVER_DATE:timestamp}%{SPACE}%{LOGLEVEL:log_level} \[%{DATA:field1}\] %{NOTSPACE:field2}
@zhangyuan
zhangyuan / gist:d41a71bca0fc11cc44f77ea864711bd9
Created December 7, 2016 05:23
remove directory regardless of the long path.
cmd /c "rmdir /S /Q \\remote_hostname_or_ip\c$\target_directory"
@zhangyuan
zhangyuan / convert_mp4_to_mp3.sh
Created December 1, 2016 06:13
convert mp4 to mp3 with ffmpeg
#!/usr/bin/env bash
for file in *.mp4;
do
ffmpeg -i "$file" -codec:a libmp3lame -qscale:a 2 "${file:0:${#file} - 4}".mp3
done
@zhangyuan
zhangyuan / gist:7a9746e7b66708774caf97d39d886fba
Created November 28, 2016 02:54
install libv8 and therubyracer
brew tap homebrew/versions
brew install v8-315
bundle config build.libv8 --with-system-v8 --with-v8-dir=/usr/local/opt/v8-315
bundle config build.therubyracer --with-system-v8 --with-v8-dir=/usr/local/opt/v8-315
bundle
@zhangyuan
zhangyuan / QueryableActiveRecord.cs
Created September 29, 2016 16:16
Make Castle.ActiveRecord work with NHibernate 3.3.3.4001
public class QueryableActiveRecord<T> : ActiveRecordBase<T>
{
public static IOrderedQueryable<T> Queryable()
{
ISession session = holder.CreateSession(typeof(T));
return new NhQueryable<T>((ISessionImplementor)session);
}
}
@zhangyuan
zhangyuan / build.gradle
Created December 26, 2015 13:24
user nexus repository for gradle
buildscript {
repositories {
maven {
url "http://127.0.0.1:8021/nexus/content/repositories/gradle/"
}
}
}
repositories {
maven {
@zhangyuan
zhangyuan / varnishd.vcl
Created July 19, 2015 08:09
simple varnish vcl configuration
backend default {
.host = "www.tonghaohui.com";
.port = "80";
}
sub vcl_recv {
set req.backend = default;
if (req.url ~ "^/w/") {
return(pass);
}