萬用滷汁
Jun 10, 2015
自製滷味, 滷汁 做法收集
Sep 3, 2014
Delete all files and subfolders under specify folder
-- delete all files and subfolders under specify folder.
FOR /D %%p IN ("D:\temp\*.*") DO rmdir "%%p" /s /q
del /q /f D:\temp\*
Oct 18, 2012
Oracle Performance Tunning Practice - INDEX RANGE SCAN with CPU high utilization
1. set autotrace on and execute sql .
Using index by "INDEX RANGE SCAN"
2. Through AWR report found the sql is top1 in SQL ordered by CPU Time part.
3. alter session set events '10046 trace name context forever, level 8';
Execute sql again and found STAT line for the traced query contains 'cnt=xxx' problem.
4. Check table records found the value are skewed cause by program bug.
5. Remove abnormal data and analyze index column .
Sep 6, 2012
SQL Server Error: 5132 ,Error: 17207 when attach DB
SQL Server Error: 5132 , Error: 17207, Severity: 16
Loss SQL Server 2005 .LDF file , when try to attach MDF/NDF facing problem.
Step 0) Copy MDF/LDF to another location for backup purpose.
Step 1) Create DB with same DB/MDF/NDF/LDF Name
Step 2) Stop SQL Service
Step 3) Replace new DB MDF/NDF file with old MDF/NDF file
Step 4) Start SQL Server
Step 5) SQL Server 2005
RECONFIGURE WITH OVERRIDE;
-- do some modification to system tables
EXEC sp_configure 'allow updates', 0
RECONFIGURE WITH OVERRIDE;
標籤: Sql Server
Aug 31, 2012
帶狀皰疹
水痘與帶狀皰疹同樣都是由同一病毒所引起。水痘是原發性感染,而帶狀皰疹是原來潛伏性感染的再活動。此病毒能夠逃避身體的免疫反應 , 即使在正常的宿主中。可能再出現在日後的生活中,特別是利用免疫力降低時出現
1. 治療必須儘早開始, 我的經驗是看診時皮膚科醫生提到三天之內塗藥與吃藥治療最有效,超過此時間治療比較無效,就需等二到三星期內消失.
2. 帶狀皰疹是否會傳染?若對水痘無免疫力者,接觸帶狀皰疹可能會感染到水痘。而對已有水痘抵抗力者,則絲毫無損。也就是說帶狀皰疹會傳染,但只傳染給一些對水痘沒有免疫力者,而受感染者亦只是發水痘而已。
3. 帶狀皰疹俗稱「皮蛇」,實因其發皰疹分佈情形成帶狀而與「皮蛇」相似而命名。看過以上帶狀皰疹的病因後,可見砍「皮蛇」能治療此病是無稽之談。
4.
「蛇」環繞全身就沒命了嗎?帶狀皰疹大多只發生於身體單側,左邊或右邊,只有約二%~十%會超過範圍到另一側,甚至全身散佈,這樣情況大都是患者原來就有其它惡性疾病,或免疫不全,其死亡的機率當然較高。因此,「沒命」的原因是來自原有的疾病,而非被「蛇」纏死了。
Jul 13, 2012
讓身體內蠢蠢欲動的癌細胞多多睡覺
讓身體內蠢蠢欲動的癌細胞多多睡覺。 1. 咖哩的重要成份「薑黃」(抗癌成份是「薑黃素」) 2. 辣椒(抗癌成份是「辣椒素」) 3. 姜(抗癌成份是「薑油」) 4. 綠茶(抗癌成份是「兒茶素」) 5. 大豆(抗癌成份是「異黃酮」) 6. 蕃茄(抗癌成份是「茄紅素」) 7. 葡萄(抗癌成份是「白黎蘆醇」) 8. 大蒜(抗癌成份是「硫化物」) 9. 高麗菜(抗癌成份是「indole」) 10. 花椰菜(抗癌成份是「硫化物」)
May 24, 2012
sharepoint 2010 user name not updating after AD display name changed
sharepoint 2010 user name not updating after AD display name changed Try using following step to solve it.: 1. Open "Sharepoint 2010 Management Shell" 2. Set-SPUser -identity "[domain]\[useraccount]” -SyncFromAD -web http://sharepointwebsite
標籤: Sharepoint 2010
Jan 30, 2012
少林氣功
Apr 29, 2011
Sharepoint list items detail about Author,Editor , assignto with mutiple values , Duedate
c# , get sharepoint list item detail about Author,Editor , assignto with mutiple values , Duedate
// Add reference Microsoft.SharePoint.Client and Microsoft.SharePoint.Client.Runtime
//
using Microsoft.SharePoint.Client;
ClientContext clientContext = new ClientContext("http://sharepointserver");
List list = clientContext.Web.Lists.GetByTitle("testlist");
clientContext.Load(list);
clientContext.ExecuteQuery();
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "";
ListItemCollection listItems = list.GetItems(camlQuery);
clientContext.Load(listItems);
clientContext.ExecuteQuery();
int i = 0;
foreach (ListItem listItem in listItems)
{
var SendToList = string.Empty;
var MailSubJect = string.Empty;
var MailBody = string.Empty;
DateTime dt = Convert.ToDateTime(Convert.ToDateTime(listItem["DueDate"]).ToLocalTime().ToString("yyyy/MM/dd"));
DateTime today = Convert.ToDateTime(DateTime.Now.ToLocalTime().ToString("yyyy/MM/dd"));
if ((dt <= today) && (listItem["Status"].ToString().Equals("Finished") == false))
{
Console.WriteLine("Id: {0} Title: {1} Author : {2} Editor : {3}",
listItem.Id, listItem["Title"],
((FieldUserValue)(listItems[i]["Author"])).LookupValue,
((FieldUserValue)(listItems[i]["Editor"])).LookupValue
);
String StartDateStr = Convert.ToDateTime(listItem["StartDate"]).ToLocalTime().ToString("yyyy/MM/dd");
String DueDateStr = Convert.ToDateTime(listItem["DueDate"]).ToLocalTime().ToString("yyyy/MM/dd");
String ModifiedStr = Convert.ToDateTime(listItem["Modified"]).ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss");
double PercentComplete = Convert.ToDouble(listItem["PercentComplete"].ToString());
PercentComplete = PercentComplete * 100;
String PercentCompleteStr = PercentComplete.ToString();
var BodyStr = string.Empty;
if (listItem["Body"]!=null)
BodyStr = listItem["Body"].ToString();
var assigntolist = string.Empty;
Type t = listItems[i]["AssignedTo"].GetType();
if (t.IsArray)
{
foreach (FieldUserValue o in listItems[i]["AssignedTo"] as FieldUserValue[])
Console.WriteLine("AssignedTo: {0}", o.LookupValue);
}
}
i = i + 1;
}
標籤: Sharepoint 2010
C# send mail by smtp with html body
C# send mail by smtp with html body. (add reference System.Net)
using System.Net.Mail;
public static void Sendalertmail(string SendToList, string MailSubJect, string MailBody)
{
string fromEmail = "Administrator@test.com";//sending email from...
string ToEmail = SendToList; //destination email
string body = MailBody;
string subject = MailSubJect;
try
{
MailMessage mm = new MailMessage(fromEmail, ToEmail);
mm.Subject = MailSubJect;
mm.Body = MailBody;
mm.IsBodyHtml = true;
SmtpClient sMail = new SmtpClient("192.168.1.1");//exchange or smtp server goes here.
sMail.DeliveryMethod = SmtpDeliveryMethod.Network;
sMail.Send(mm);
}
catch (Exception ex)
{
//do something
}
}
標籤: Sharepoint 2010
Get sharepoint user name or email address
c# get sharepoint user name or email address
-------
static public string GetUserEMail(object user, ClientContext context)
{
Dictionary
if (user == null)
{
return string.Empty;
}
var username = string.Empty;
var useremail = string.Empty;
var spUser = user as FieldUserValue;
if (spUser != null)
{
if (!userNameCache.TryGetValue(spUser.LookupId, out useremail))
{
var userInfoList = context.Web.SiteUserInfoList;
context.Load(userInfoList);
var query = new CamlQuery { ViewXml = "
var users = userInfoList.GetItems(query);
context.Load(users, items => items.Include(
item => item.Id,
item => item["Name"]));
var principal = users.GetById(spUser.LookupId);
context.Load(principal);
context.ExecuteQuery();
username = principal["Name"] as string;
useremail = username.Substring(username.IndexOf("\\") + 1) + "@test.com";
userNameCache.Add(spUser.LookupId, useremail);
}
}
return useremail;
}
標籤: Sharepoint 2010
Apr 14, 2011
Proxy Autoconfig , PAC
In Browser , setting as use PAC.
http://proxycfg/browser.pac
browser.pac content is as :
function FindProxyForURL(url, host)
{
if (isPlainHostName(host) ||
shExpMatch(url, "*.mycompany.*") ||
isInNet(host, "192.168.0.0", "255.255.0.0"))
return "DIRECT";
if (isInNet(myIpAddress(), "192.168.0.0", "255.255.240.0"))
return "PROXY proxy.mycompany.com:3128; DIRECT";
else
return "PROXY proxy.othersite.com:8080; DIRECT";
}
-- Description
isPlainHostName(host) -> check if local lan server
shExpMatch(url, "*.mycompany.*") -> check url use local web site server
isInNet(host, "192.168.0.0", "255.255.0.0")) -> check server IP if in LAN
isInNet(myIpAddress(), "192.168.0.0", "255.255.240.0") -> CHeck if My IP address is in local site subnet
Feb 22, 2011
SQL Server using decode / instr function
1. "charindex('Taiwan',description)" can be act as instr.
2. "case WHEN charindex('Taiwan',description) > 0 then 'Taiwan Local' else 'Other contury' end as location" can be act as decode.
3. full sql is like :
select mac,description,case WHEN charindex('Taiwan',description) > 0 then 'Taiwan Local' else 'Other contury' end as location from tmpdata
標籤: Sql Server
Jan 7, 2011
Sharepoint 2010 disable user "alert me"
There are two ways to disable "alert me"
1. Sharepoint administration -> application management -> Web Application -> Manage web application -> Application Ex. 80 , then "general Settings"
-> set "Alerts" option as "off"
2. Through permission level , remove "alert me".
標籤: Sharepoint 2010
Sharepoint 2010 master page layout , fix content display width .
1.
## Copy v4.master as custom.master , and set as default master page , and then under <head> , above </head> add following code -> style type="text/css" ...
<style type="text/css">
.s4-specialNavLinkList
{
display:none !important;
}
.ms-cui-ribbonTopBars > DIV {
MARGIN: 0px auto; WIDTH: 1000px; FLOAT: none
}
UL.ms-cui-tabBody {
MARGIN: 0px auto; WIDTH: 1000px; FLOAT: none
}
BODY #s4-titlerow > DIV {
MARGIN: 0px auto; WIDTH: 1000px; FLOAT: none
}
#s4-bodyContainer > DIV {
MARGIN: 0px auto; WIDTH: 1000px; FLOAT: none
}
.s4-help {
DISPLAY: none !important;
}
.s4-search {
DISPLAY: none !important;
}
.s4-titletext {
DISPLAY: none !important;
}
body #s4-leftpanel{font-size: 10pt !important; font-family: Verdana !important;}
</style>
2. Hide the left panel at all.
1. Site Actions > Edit Page >
2. # Insert > Web Part (or add a Web Part to a Web Part zone)
3. # Under Media and Content select Content Editor and click Add , then save
4. Enter the following HTML / CSS into content and click OK
<style type="text/css">
body #s4-leftpanel { display: none; }
.s4-ca { margin-left: 0px; }
</style>
## There is a good reference doc for sharepoint 2010 layout component at http://erikswenson.blogspot.com/2010/01/sharepoint-2010-base-css-classes.html
標籤: Sharepoint 2010
Nov 2, 2010
Sharepoint 2010 connect to sql server and oracle database
1. Menu add connection strings in c:\inetpub\wwwroot\wss\VirtualDirectories\
Ex.
/* for sql server and oracle*/
<connectionStrings>
<add name="AdventureWorksConnectionString" connectionString="Data Source=192.168.0.1;Initial Catalog=AdventureWorks;User Id=sa;Password=smpsqladm1" />
<add name="OracleConnectionString" connectionString="Data Source=Ora_TEST;User ID=system;Password=system_pwd" providerName="System.Data.OracleClient" />
</connectionStrings>
2. In Sharepoint virtual web part ascx file .
<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px"
DataSourceID="SqlDataSource1" EnableModelValidation="True">
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:AdventureWorksConnectionString%>"
SelectCommand="select count(*) as intUnRead from yourtable">
</asp:SqlDataSource>
<asp:DetailsView ID="DetailsView2" runat="server" Height="50px" Width="125px"
DataSourceID="SqlDataSource2" EnableModelValidation="True">
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:OracleConnectionString %>"
ProviderName="System.Data.OracleClient"
SelectCommand="select count(*) as UnRead from testtable">
</asp:SqlDataSource>
標籤: Sharepoint 2010
Nov 1, 2010
Using Visual Studio 2010 add connect string to Sharepoint 2010 to query database data
1. From VS2010 , add new sharepoint 2010 empty project as , and then add one new item "Virtual Web Part" name as "SQLWebPartTest"
2. In "SQLWebPartTest" ascx file , manual add codes for DetailsView and SqlDataSource .
-----------
<asp:DetailsView ID="DetailsView1" runat="server"
DataSourceID="SqlDataSource1" EnableModelValidation="True">
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ChangebyYourConnectionString %>"
SelectCommand="select * from ChangebyYourTable">
</asp:SqlDataSource>
<asp:DetailsView ID="DetailsView2" runat="server"
DataSourceID="SqlDataSource2" EnableModelValidation="True">
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:ChangebyYourConnectionString2 %>"
SelectCommand="select * from ChangebyYourTable">
</asp:SqlDataSource>
--------------
3. In the project "Solution Explorer" , right click in "Feature1" to add one "Event Receiver" and name it as "Feature1.EventReceiver.cs"
--- In "Feature1.EventReceiver.cs"
#1 Add using
using System.Reflection;
using Microsoft.SharePoint.Administration;
#2 Add following code in "public class Feature1EventReceiver : SPFeatureReceiver"
private ModificationEntry[] entries =
{
//Ensure there's a connectionStrings section.
new ModificationEntry(
"connectionStrings"
,"configuration"
,"<connectionStrings/>"
,SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode
,true)
//Create the connectionstring.
,new ModificationEntry(
"add[@name='ChangebyYourConnectionString'][@connectionString='Data Source=192.168.0.1;Initial Catalog=ChangebyYourDB;User Id=ChangebyYourID;Password=ChangebyYourPWD']"
,"configuration/connectionStrings"
,"<add name='ChangebyYourConnectionString' connectionString='Data Source=192.168.0.1;Initial Catalog=ChangebyYourDB;User Id=ChangebyYourID;Password=ChangebyYourPWD'/>"
,SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode
,false)
,new ModificationEntry(
"add[@name='ChangebyYourConnectionString2'][@connectionString='Data Source=192.168.0.100;Initial Catalog=AdventureWorks;User Id=ChangebyYourID;Password=ChangebyYourPWD']"
,"configuration/connectionStrings"
,"<add name='ChangebyYourConnectionString2' connectionString='Data Source=192.168.2.100;Initial Catalog=AdventureWorks;User Id=ChangebyYourID;Password=ChangebyYourPWD'/>"
,SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode
,false)
};
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
//Get a reference to the web application and then remove entries for the blorum.
SPSite site = properties.Feature.Parent as SPSite;
SPWebApplication webApplication = site.WebApplication;
site.RootWeb.Title = "Set from activating code at " + DateTime.Now.ToString();
site.RootWeb.Update();
foreach (ModificationEntry entry in entries)
{
webApplication.WebConfigModifications.Add(CreateModification(entry));
}
webApplication.WebService.WebConfigModifications.Clear();
webApplication.WebService.ApplyWebConfigModifications();
}
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
SPSite site = properties.Feature.Parent as SPSite;
SPWebApplication webApplication = site.WebApplication;
site.RootWeb.Title = "Set from deactivating code at " + DateTime.Now.ToString();
site.RootWeb.Update();
foreach (ModificationEntry entry in entries)
{
if (!entry.CreateOnly)
webApplication.WebConfigModifications.Remove(CreateModification(entry));
}
webApplication.WebService.ApplyWebConfigModifications();
}
private SPWebConfigModification CreateModification(ModificationEntry entry)
{
SPWebConfigModification modification = new SPWebConfigModification(entry.Name, entry.XPath);
modification.Owner = Assembly.GetExecutingAssembly().FullName;
modification.Sequence = 0;
modification.Type = entry.ModificationType;
modification.Value = entry.Value;
return modification;
}
private struct ModificationEntry
{
public string Name;
public string XPath;
public string Value;
public SPWebConfigModification.SPWebConfigModificationType ModificationType;
public bool CreateOnly;
public ModificationEntry(string name, string xPath, string value,
SPWebConfigModification.SPWebConfigModificationType modificationType, bool createOnly)
{
Name = name;
XPath = xPath;
Value = value;
ModificationType = modificationType;
CreateOnly = createOnly;
}
}
4. Press F5 in VS2010 to open Sharepoint site , and insert add webpart from "custom" location.
標籤: Sharepoint 2010
Jun 9, 2010
Open large text file fast and consume little resource tool
Open large text file fast and consume little resource tool.
I try to open a .txt file with 300MB size by notepad/notepad++ , those txt editor use lots of memory and slow my windows system. Finally the pop-up message show me "file too large,cannot open.".
After try to use "LTFViewer" to open the large file, the performance is very good and only a little resource to by occupy.
http://www.swiftgear.com/fltfviewer/fLTFViewr.zip
Apr 7, 2010
Get windows eventlog and specified time record
'This vbscript is for retrieve windows eventlog "Application" , SourceName="YourService.exe" , EventCode=1 log record
' and then execute c:\maint\batch\execproc.bat to do something
Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
'1440 is one day , "Now - 3/1440" is represent for 3 minutes ago
DateToCheck = Now - 3/1440
dtmStartDate.SetVarDate DateToCheck, True
intNumberID=1
Set objWMI = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colLoggedEvents = objWMI.ExecQuery _
("Select * from Win32_NTLogEvent Where Logfile = 'Application' and TimeWritten >='" & dtmStartDate & "'")
For Each objEvent in colLoggedEvents
If objEvent.EventCode = intNumberID Then
if objEvent.SourceName="YourService.exe" then
Set shell = CreateObject("WScript.Shell")
Set exec = shell.run("c:\maint\batch\execproc.bat")
end if
End if
Next
WScript.Quit
Mar 3, 2010
Hide user from exchange address list by msExchHideFromAddressLists
' Setup ADO objects.
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
Set adoCommand.ActiveConnection = adoConnection
' Search entire Active Directory domain.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase = "
' Filter on user objects.
strFilter = "(&(objectCategory=person)(objectClass=user))"
' Comma delimited list of attribute values to retrieve.
strAttributes = "sAMAccountName,cn,distinguishedName"
' Construct the LDAP syntax query.
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False
' Run the query.
Set adoRecordset = adoCommand.Execute
' Enumerate the resulting recordset.
Do Until adoRecordset.EOF
' Retrieve values and display.
strName = adoRecordset.Fields("sAMAccountName").Value
strDName = adoRecordset.Fields("distinguishedName").Value
strCN = adoRecordset.Fields("cn").value
'Change "test_admin" to your data
if strName="test_admin" then
'Wscript.Echo "NT Name: " & strName & ", distinguishedName: " & strDName
Set oUser = GetObject("LDAP://"&strDName)
oUser.put "msExchHideFromAddressLists", True
oUser.SetInfo
ExchangeAddressList="Disabled"
end if
' Move to the next record in the recordset.
adoRecordset.MoveNext
Loop
' Clean up.
adoRecordset.Close
adoConnection.Close