Skip to content

Instantly share code, notes, and snippets.

View wellwind's full-sized avatar

Mike Huang wellwind

View GitHub Profile
  1. ng new nativescript-with-ng-cli
  2. cd nativescript-with-ng-cli
  3. rm -rf src
  4. tns create src --ng
  5. .gitignore
# NativeScript
src/node_modules
src/platforms
@wellwind
wellwind / allow.sh
Last active January 5, 2017 09:09
Ubuntu Firewall
sudo ufw allow from 140.119.210.170 to any port 21
sudo ufw status numbered
sudo ufw delete numbered
@wellwind
wellwind / global.asax
Created September 30, 2016 13:09
Asp.Net MVC handle error sample
public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_EndRequest()
{
if (Context.Response.StatusCode == 200)
{
return;
}
Response.Clear();
Response.ContentType = "text/json";
  1. Update
sudo apt-get update
sudo apt-get upgrade

sudo rpi-update
  1. reboot
@wellwind
wellwind / NSubstitute.TestUtils.DbContextExtensions.cs
Last active June 22, 2017 06:56
NSubstitute模擬Entity Framework的DbContext用的Extension
public static class DbContextExtensions
{
/// <summary>
/// 從ScenarioContext中取得IDbSet&lt;T&gt;,並加入dbContext中。
/// 其中propertyName若不指定則預設用T的名稱。
/// ex1: IDbSet&lt;SomeClass&gt; SomeClass
/// 在不指定propertyName時會將內容加入dbContext.SomeClass中。
/// ex2: IDbSet&lt;SomeClass&gt; AnotherName
/// 若需要使用dbContext.AnotherName則必須將propertyName設為"AnotherName"。
/// </summary>
@wellwind
wellwind / todo_list.jsx
Last active April 3, 2016 02:42
[程式碼片段][React速成班]從TodoList範例學習React(3)-透過實作AddTodoForm學習state, 文章網址: https://dotblogs.com.tw/wellwind/2016/04/03/react-tutorial-7-state
var TodoItem = React.createClass({
render: function(){
return (<li key={this.props.key}>{this.props.children}</li>);
}
})
var TodoItems = React.createClass({
render: function() {
var displayItems = this.props.items.map(function(item) {
return (<TodoItem key={item.id}>{item.data}</TodoItem>);
@wellwind
wellwind / todo_list.jsx
Last active August 1, 2017 07:11
[程式碼片段][React速成班]從TodoList範例學習React(2)-透過實作TodoItems學習props, 文章網址:https://dotblogs.com.tw/wellwind/2016/03/18/react-tutorial-6-props
var TodoItem = React.createClass({
render: function(){
return (<li key={this.props.key}>{this.props.children}</li>);
}
})
var TodoItems = React.createClass({
render: function() {
var displayItems = this.props.items.map(function(item) {
// return (<li key={item.id}>{item.data}</li>);
@wellwind
wellwind / ClearVisualStudioComponentModelCache.bat
Created February 23, 2016 03:04
Clear Visual Studio component model cache, it's useful when visual studio crash but have no ideal how to fix.
DEL %userprofile%\AppData\Local\Microsoft\VisualStudio\10.0\ComponentModelCache
DEL %userprofile%\AppData\Local\Microsoft\VisualStudio\12.0\ComponentModelCache
DEL %userprofile%\AppData\Local\Microsoft\VisualStudio\14.0\ComponentModelCache
@wellwind
wellwind / AutoMapperFromDataTableToList.cs
Created December 13, 2015 05:23
使用AutoMapper來將DataTable轉成強行別List<T>
public class MapperHelper
{
public static IList<T> GetDataFromDataTable<T>(DataSet dataSet, int dataTableIndex)
{
var table = dataSet.Tables[dataTableIndex];
using (var reader = dataSet.CreateDataReader(table))
{
return Mapper.Map<IList<T>>(reader).ToList();
}
}
@wellwind
wellwind / 01.ApiResponseSample_Normal.js
Last active July 30, 2019 01:19
ASP.NET WebApi自訂回傳訊息Demo
{
"StatusCode": 200,
"Result": {
Name = "Wellwind",
Age = 30
},
"Error": null
}