Skip to content

Instantly share code, notes, and snippets.

View huoxudong125's full-sized avatar
💭
I may be slow to respond.

Frank Huo huoxudong125

💭
I may be slow to respond.
View GitHub Profile
URL="http://stackoverflow.com/"
# store the whole response with the status at the and
HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X POST $URL)
# extract the body
HTTP_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g')
# extract the status
HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
// Run this in the F12 javascript console in chrome
// if a redirect happens, the page will pause
// this helps because chrome's network tab's
// "preserve log" seems to technically preserve the log
// but you can't actually LOOK at it...
// also the "replay xhr" feature does not work after reload
// even if you "preserve log".
window.addEventListener("beforeunload", function() { debugger; }, false)
@huoxudong125
huoxudong125 / README.md
Created September 18, 2017 00:57 — forked from magnetikonline/README.md
PowerShell example to copy local files recursively to target server share with orphan cleanup.

PowerShell copy local files recursively to target server

A PowerShell script which provides the following:

  • Mount remote/target server share with given username/password credentials.
  • Copy all $SourcePath files to target share ($TargetServer / $TargetShare) recursively.
  • Finally, clean up all orphaned directories/files from target share.

Usage example

./remotecopy.ps1 `
	-SourcePath "." `
<#
.SYNOPSIS
Gets a PowerShell Credential (PSCredential) from the Windows Credential Manager
.DESCRIPTION
Adapted from: http://stackoverflow.com/questions/7162604/get-cached-credentials-in-powershell-from-windows-7-credential-manager
.PARAMETER TargetName
The name of the target login informations in the Windows Credential Manager
<#
.SYNOPSIS
Find MAC Address Vendors
.DESCRIPTION
Lookup Vendor of MAC Address regsitered on IEEE.org (Institute of Electrical and Electronics Engineers) database
.PARAMETER MACAddress
MAC address to lookup
@huoxudong125
huoxudong125 / alibaba maven mirror
Created August 22, 2017 08:28 — forked from NeoOU/alibaba maven mirror
alibaba maven mirror
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
@huoxudong125
huoxudong125 / npm-cheat-sheet.md
Created July 21, 2017 06:26 — forked from AvnerCohen/npm-cheat-sheet.md
Node.js - npm Cheat Sheet

Node.js - npm Cheat Sheet

(Full description and list of commands at - https://npmjs.org/doc/index.html)

##List of less common (however useful) NPM commands

######Prepand ./bin to your $PATH Make sure to export your local $PATH and prepand relative ./node_modules/.bin/:

public class ApiLogEntry
{
public long ApiLogEntryId { get; set; } // The (database) ID for the API log entry.
public string Application { get; set; } // The application that made the request.
public string User { get; set; } // The user that made the request.
public string Machine { get; set; } // The machine that made the request.
public string RequestIpAddress { get; set; } // The IP address that made the request.
public string RequestContentType { get; set; } // The request content type.
public string RequestContentBody { get; set; } // The request content body.
public string RequestUri { get; set; } // The request URI.
public class ApiLogHandler : DelegatingHandler
{
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
var apiLogEntry = CreateApiLogEntryWithRequestData(request);
if (request.Content != null)
{
await request.Content.ReadAsStringAsync()
.ContinueWith(task =>
{
@huoxudong125
huoxudong125 / OrderBy Expression.cs
Last active November 21, 2017 06:59 — forked from neoGeneva/gist:1878868
An OrderBy extension method for IQueryable that takes string
public static IQueryable<T> OrderBy<T>(this IQueryable<T> source, string sortExpression)
{
if (source == null)
throw new ArgumentNullException("source", "source is null.");
if (string.IsNullOrEmpty(sortExpression))
throw new ArgumentException("sortExpression is null or empty.", "sortExpression");
var parts = sortExpression.Split(' ');