<!DOCTYPE html>
<html>
<head>
<script>
// Check for the various File API support.
if (window.File && window.FileReader && window.FileList && window.Blob) {
// Great success! All the File APIs are supported.
} else {
alert('The File APIs are not fully supported in this browser.');
}
</script>
<div id="drop_zone">Drop files here</div>
<output id="list"></output>
<script>
function handleFileSelect(evt) {
evt.stopPropagation();
evt.preventDefault();
var files = evt.dataTransfer.files; // FileList object.
// files is a FileList of File objects. List some properties.
var output = [];
for (var i = 0, f; f = files[i]; i++) {
output.push('<li><strong>', escape(f.name), '</strong> (', f.type || 'n/a', ') - ',
f.size, ' bytes, last modified: ',
f.lastModifiedDate ? f.lastModifiedDate.toLocaleDateString() : 'n/a',
'</li>');
}
document.getElementById('list').innerHTML = '<ul>' + output.join('') + '</ul>';
}
function handleDragOver(evt) {
evt.stopPropagation();
evt.preventDefault();
evt.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.
}
// Setup the dnd listeners.
var dropZone = document.getElementById('drop_zone');
dropZone.addEventListener('dragover', handleDragOver, false);
dropZone.addEventListener('drop', handleFileSelect, false);
</script>
</head>
</html>
Daniel Code
Someone who loves DATA very much
06/06/2016
24/02/2016
[VBS]IE fill form and submit
Option Explicit
Dim ie, ipf
Set ie = CreateObject("InternetExplorer.Applicati on")
On Error Resume Next
Sub WaitForLoad
Do While IE.Busy
WScript.Sleep 500
Loop
End Sub
Sub Find(x)
Set ipf = ie.Document.All.Item(x)
End Sub
ie.Left = 0
ie.Top = 0
ie.Toolbar = 0
ie.StatusBar = 0
ie.Height = 120
ie.Width = 1020
ie.Resizable = 0
ie.Navigate "https://www.facebook.com/"
Call WaitForLoad
ie.Visible = True
Call Find("email")
ipf.Value = "EMAIL GOES HERE"
Call Find("pass")
ipf.Value = "PASSWORD GOES HERE"
Call Find("login_form")
ipf.Submit
Call WaitForLoad
ie.Height = 700
________________________________________ ______________
Know the Basics:
---------------------------------------- ---------------------------------------- ----------
Set ie = CreateObject("InternetExplorer.Applicati on")
ie.Document.All.Item("INPUT ID").Value = "what you want"
ie.Document.All.Item("FORM ID).Submit
---------------------------------------- ---------------------------------------- ----------
Dim ie, ipf
Set ie = CreateObject("InternetExplorer.Applicati
On Error Resume Next
Sub WaitForLoad
Do While IE.Busy
WScript.Sleep 500
Loop
End Sub
Sub Find(x)
Set ipf = ie.Document.All.Item(x)
End Sub
ie.Left = 0
ie.Top = 0
ie.Toolbar = 0
ie.StatusBar = 0
ie.Height = 120
ie.Width = 1020
ie.Resizable = 0
ie.Navigate "https://www.facebook.com/"
Call WaitForLoad
ie.Visible = True
Call Find("email")
ipf.Value = "EMAIL GOES HERE"
Call Find("pass")
ipf.Value = "PASSWORD GOES HERE"
Call Find("login_form")
ipf.Submit
Call WaitForLoad
ie.Height = 700
________________________________________
Know the Basics:
----------------------------------------
Set ie = CreateObject("InternetExplorer.Applicati
ie.Document.All.Item("INPUT ID").Value = "what you want"
ie.Document.All.Item("FORM ID).Submit
----------------------------------------
22/02/2016
[JS]keycode
document.onkeydown = function(){
var x = event.keyCode;
if(x==112){
datamart_js();
}
}
f1 112
f2 113
f3 114
f4 115
f5 116
f6 117
f7 118
f8 119
f9 120
f10 121
f11 122
f12 123
var x = event.keyCode;
if(x==112){
datamart_js();
}
}
f1 112
f2 113
f3 114
f4 115
f5 116
f6 117
f7 118
f8 119
f9 120
f10 121
f11 122
f12 123
13/02/2016
[SAS]Macro
options symbolgen mprint;
/*symbolgen -> macro variale ( ) resolves to ( )*/
/*mprint -> output is written to the SAS log:*/
options nosymbolgen nomprint;
07/02/2016
[SAS]Comment and fix error
/* '; * "; */;
quit;
run;
*---------------------------------------*
| This uses one comment statement |
| to draw a box. |
*---------------------------------------*;
quit;
run;
*---------------------------------------*
| This uses one comment statement |
| to draw a box. |
*---------------------------------------*;
[SAS]Proc SQL
proc sql; /* required */
create table mytable as select ...; /* 1 - new table */
create view myview as select ...; /* 2 - new view */
select ...; /* 3 - powerful query tool */
alter table mytable ...; /* 4 - new table structure */
update table mytable ...; /* 5 - update table content */
insert table mytable ...; /* 6 - update table content */
delete from table mytable ...; /* 7 - delete table content */
drop table mytable; /* 8 - delete table */
quit; /* required */
create table mytable as select ...; /* 1 - new table */
create view myview as select ...; /* 2 - new view */
select ...; /* 3 - powerful query tool */
alter table mytable ...; /* 4 - new table structure */
update table mytable ...; /* 5 - update table content */
insert table mytable ...; /* 6 - update table content */
delete from table mytable ...; /* 7 - delete table content */
drop table mytable; /* 8 - delete table */
quit; /* required */
03/02/2016
[DOS command]Dan
@ECHO off
echo ████ ███ █ █
echo █ █ █ █ ██ █
echo █ █ █ █ █ █ █
echo █ █ █ █ █ █ █
echo █ █ █████ █ █ █
echo █ █ █ █ █ █ █
echo █ █ █ █ █ ██
echo ████ █ █ █ █
@PAUSE
echo ████ ███ █ █
echo █ █ █ █ ██ █
echo █ █ █ █ █ █ █
echo █ █ █ █ █ █ █
echo █ █ █████ █ █ █
echo █ █ █ █ █ █ █
echo █ █ █ █ █ ██
echo ████ █ █ █ █
@PAUSE
16/01/2016
[VBS]Network Object
ServerShare = "\\192.168.3.56\d$"
UserName = "domain\username"
Password = "password"
Set NetworkObject = CreateObject("WScript.Network")
Set FSO = CreateObject("Scripting.FileSystemObject")
NetworkObject.MapNetworkDrive "", ServerShare, False, UserName, Password
Set Directory = FSO.GetFolder(ServerShare)
For Each FileName In Directory.Files
WScript.Echo FileName.Name
Next
Set FileName = Nothing
Set Directory = Nothing
Set FSO = Nothing
NetworkObject.RemoveNetworkDrive ServerShare, True, False
Set ShellObject = Nothing
Set NetworkObject = Nothing
02/01/2016
[R]Vectors and assignment
function c()
x <- c(10.4, 5.6, 3.1, 6.4, 21.7)
assign("x", c(10.4, 5.6, 3.1, 6.4, 21.7))
y <- c(x, 0, x) #create a vector y with 11 entries
x <- c(10.4, 5.6, 3.1, 6.4, 21.7)
assign("x", c(10.4, 5.6, 3.1, 6.4, 21.7))
y <- c(x, 0, x) #create a vector y with 11 entries
31/12/2015
[Excel]IF Function
一、IF
作用:根据条件进行判断并返回不同的值。
示例:
1、如果A1单元格值大于100,显示“完成”,否则显示“未完成”
=IF(A1>100,"完成","未完成")
2、判断成绩
=IF(A1<60,"不及格",IF(A1<80,"良好","优秀"))
3、如果A1的值大于60并且B1不为空,显示“已结束”否则显示“未结束”
=IF(AND(A1>60,B1<>""),"已结束","未结束")
二、IFerror
作用:把错误值显示为指定的内容
示例:
1、如果A1/B1返回错误值,则显示空
=Iferror(a1/b1,"")
2、如果Vlookup查找不到值,则显示空
=Iferror(vlookup(省略),"")
三、CountIF
作用:根据条件统计个数
示例:
1、计算A列有多少财务部的人员
=Countif(a:a,"财务部")
2、计算A列有多少个包括“北京”的公司名称
=Countif(a:a,"*北京*)
四、SumIF
作用:根据条件求和
1、统计C列大于1000的销售金额之和
=Sumif(c:c,">1000")
2、统计A列产品为“三星”所对应B列的销售个数
=Sumif(a:a,"三星",b:b)
五、CountIFs
作用:多条件计数
示例:
1、公司1的人事部有多少人(A列公司名称,B列部门名称)
=COUNTIFS(A2:A11,"公司1",B2:B11,"人事部")
2、工资在3000~4000之间的有多少人(D列为工资)
=COUNTIFS(D2:D11,">3000",D2:D11,"<4000")
六、SumIFs
作用:多条件求和
示例:
1、公司1人事部工资和(A列公司名称,B列部门名称。D列工资)
=SUMIFS(D2:D11,A2:A11,"公司1",B2:B11,"人事部")
2、A列为"电视",B列包括34的C列数量之和
=Sumifs(C:C,A:A,"电视",b:b,"*34*")
七、AverageIF
作用:根据条件计算平均数
示例:
1、计算C列单价小于10的平均单价。
=AVERAGEIF(C:C,"<10")
2、计算C产品的平均单价(A列为产品名称)
=AVERAGEIF(A:A,"C",B:B)
八、AverageIFs
作用:多条件计算平均值
示例:
1、计算甲公司,经理级的平均工资(A列公司名,B列职称,C列工资金额)
=AVERAGEIFS(D2:D11,A2:A11,"甲公司",B2:B11,"经理")
2、统计工资在4000~8000之间的平均工资
=AVERAGEIFS(D2:D11,D2:D11,">4000",D2:D11,"<8000")
29/12/2015
[SAS]Proc Logistic
***Predicting the probability of getting into graduate school (admit=1) versus not getting in (admit=0)
(Predicting the probability of Y=1 vs Y=0) proc logistic data=data.binary descending;
class rank / param=ref ;
model admit = gre gpa rank;
run;
|
| Model Information | ||
|---|---|---|
| Data Set | DATA.BINARY | Written by SAS |
| Response Variable | ADMIT | |
| Number of Response Levels | 2 | |
| Model | binary logit | |
| Optimization Technique | Fisher's scoring | |
| Number of Observations Read | 400 |
|---|---|
| Number of Observations Used | 400 |
| Response Profile | ||
|---|---|---|
| Ordered Value |
ADMIT | Total Frequency |
| 1 | 1 | 127 |
| 2 | 0 | 273 |
Probability modeled is ADMIT=1.
| Class Level Information | ||||
|---|---|---|---|---|
| Class | Value | Design Variables | ||
| RANK | 1 | 1 | 0 | 0 |
| 2 | 0 | 1 | 0 | |
| 3 | 0 | 0 | 1 | |
| 4 | 0 | 0 | 0 | |
| Model Convergence Status |
|---|
| Convergence criterion (GCONV=1E-8) satisfied. |
| Model Fit Statistics | ||
|---|---|---|
| Criterion | Intercept Only | Intercept and Covariates |
| AIC | 501.977 | 470.517 |
| SC | 505.968 | 494.466 |
| -2 Log L | 499.977 | 458.517 |
The portion of the output labeled Model Fit Statistics describes and tests the overall fit of the model. The -2 Log L (499.977) can be used in comparisons of nested models.
| Testing Global Null Hypothesis: BETA=0 | |||
|---|---|---|---|
| Test | Chi-Square | DF | Pr > ChiSq |
| Likelihood Ratio | 41.4590 | 5 | <.0001 |
| Score | 40.1603 | 5 | <.0001 |
| Wald | 36.1390 | 5 | <.0001 |
The likelihood ratio chi-square of 41.4590 with a p-value of 0.0001 tells us that our model as a whole fits significantly better than an empty model.
The Score and Wald tests are asymptotically equivalent tests of the same hypothesis tested by the likelihood ratio test, not surprisingly, these tests also indicate that the model is statistically significant.
| Type 3 Analysis of Effects | |||
|---|---|---|---|
| Effect | DF | Wald Chi-Square |
Pr > ChiSq |
| GRE | 1 | 4.2842 | 0.0385 |
| GPA | 1 | 5.8714 | 0.0154 |
| RANK | 3 | 20.8949 | 0.0001 |
| Analysis of Maximum Likelihood Estimates | ||||||
|---|---|---|---|---|---|---|
| Parameter | DF | Estimate | Standard Error |
Wald Chi-Square |
Pr > ChiSq | |
| Intercept | 1 | -5.5414 | 1.1381 | 23.7081 | <.0001 | |
| GRE | 1 | 0.00226 | 0.00109 | 4.2842 | 0.0385 | |
| GPA | 1 | 0.8040 | 0.3318 | 5.8714 | 0.0154 | |
| RANK | 1 | 1 | 1.5514 | 0.4178 | 13.7870 | 0.0002 |
| RANK | 2 | 1 | 0.8760 | 0.3667 | 5.7056 | 0.0169 |
| RANK | 3 | 1 | 0.2112 | 0.3929 | 0.2891 | 0.5908 |
This shows the coefficients (labeled Estimate), their standard errors (error), the Wald Chi-Square statistic, and associated p-values. The coefficients for gre, and gpa are statistically significant, as are the terms for rank=1 and rank=2 (versus the omitted category rank=4). The logistic regression coefficients give the change in the log odds of the outcome for a one unit increase in the predictor variable.
- For every one unit change in gre, the log odds of admission (versus non-admission) increases by 0.002.
- For a one unit increase in gpa, the log odds of being admitted to graduate school increases by 0.804.
- The coefficients for the categories of rank have a slightly different interpretation. For example, having attended an undergraduate institution with arank of 1, versus an institution with a rank of 4, increases the log odds of admission by 1.55.
| Odds Ratio Estimates | |||
|---|---|---|---|
| Effect | Point Estimate | 95% Wald Confidence Limits | |
| GRE | 1.002 | 1.000 | 1.004 |
| GPA | 2.235 | 1.166 | 4.282 |
| RANK 1 vs 4 | 4.718 | 2.080 | 10.701 |
| RANK 2 vs 4 | 2.401 | 1.170 | 4.927 |
| RANK 3 vs 4 | 1.235 | 0.572 | 2.668 |
This gives the coefficients as odds ratios. An odds ratio is the exponentiated coefficient, and can be interpreted as the multiplicative change in the odds for a one unit change in the predictor variable.
For a one unit increase in gpa, the odds of being admitted to graduate school (versus not being admitted) increase by a factor of 2.24.
| Association of Predicted Probabilities and Observed Responses | |||
|---|---|---|---|
| Percent Concordant | 69.1 | Somers' D | 0.386 |
| Percent Discordant | 30.6 | Gamma | 0.387 |
| Percent Tied | 0.3 | Tau-a | 0.168 |
| Pairs | 34671 | c | 0.693 |
26/12/2015
[Excel]Notes for Excel 2010 Expert - Applying formula and function
=sum(A1:B1)
=sum(A1:B1,A2:B2) *two range
=sum(A1:B1 A1:A2) *only the overlap cell
press Ctrl many cell and input text then Ctrl + Enter to multi-input
=index(array,row_num,column_num)
=match(lookup_value,lookup_array,match_type)
=rank.eq(num,ref,order)
=mode.sngl(num1,num2...)
=choose(index_num,vaalue1,value2) *set 1 to text1 and 2 to text2
=text(value,format_text) * turn num to string
=sum(A1:B1,A2:B2) *two range
=sum(A1:B1 A1:A2) *only the overlap cell
press Ctrl many cell and input text then Ctrl + Enter to multi-input
=index(array,row_num,column_num)
=match(lookup_value,lookup_array,match_type)
=rank.eq(num,ref,order)
=mode.sngl(num1,num2...)
=choose(index_num,vaalue1,value2) *set 1 to text1 and 2 to text2
=text(value,format_text) * turn num to string
19/12/2015
[R]Basic syntax
Declare variable
x<-2
x<-y<-7
Remove variable
rm(x)
Check data type: numeric/character/date/Logical
class(x)
is.numeric(x)
Assign integer
x<-5L
is.integer(x)
x<-2
x<-y<-7
Remove variable
rm(x)
Check data type: numeric/character/date/Logical
class(x)
is.numeric(x)
Assign integer
x<-5L
is.integer(x)
15/12/2015
[SAS]Change the Work location to D:\ drive
Change Target to:
"C:\Program Files\SAS Institute\SAS\V8\sas.exe" -CONFIG "C:\Program Files\SAS Institute\SAS\V8\SASV8.CFG" -work "D:\temp"
"C:\Program Files\SAS Institute\SAS\V8\sas.exe" -CONFIG "C:\Program Files\SAS Institute\SAS\V8\SASV8.CFG" -work "D:\temp"
Run below code to check:
03/10/2015
[DOS command]Menu & Error checking
@echo off
CLS
TITLE Daniel Application Menu
echo.
echo ***************************************
echo * *
echo * Daniel Application Menu *
echo * *
echo ***************************************
echo.
echo 1 - Datamart and File Status Checking
echo 2 - Log Error Checking
echo.
echo.
::command to call different bat
set /p "cmd=Enter the command [Q > Exit]:"
IF %cmd% EQU 1 (
call "F:\project_DOS command\batch - Status checking.bat"
) ELSE (
IF %cmd% EQU 2 (
call "F:\project_DOS command\batch - Log error checking.bat"
) ELSE (
IF %cmd% EQU Q (
Exit
) ELSE (
echo Wrong Command
)))
pause
________________________________________________________________
@echo off
CLS
Title Error checking
call:checkerror "F:\project_DOS command\error(201509).log" test
::report layout
echo.
echo ***********************************
echo * *
echo * Error Checking *
echo * *
echo ***********************************
echo.
echo file name Error count
echo _____________________________________________
echo error(201509).txt %error_cnt_test%
echo.
echo.
::report layout
::command to call different bat
set /p "cmd=Enter the (0 to menu ; Q to Quit):
IF %cmd% EQU 0 (
call "F:\project_DOS command\Menu.bat"
) ELSE (
IF %cmd% EQU Q (
Exit
) ELSE (
call "F:\project_DOS command\batch - Log error checking.bat"
))
pause
::Funciton Declare
:checkerror
set "file=%~1"
set /a cnt=0
for /f %%a in ('type "%file%"^|find /I /c "error"') do set /a error_cnt_%2=%%a
CLS
TITLE Daniel Application Menu
echo.
echo ***************************************
echo * *
echo * Daniel Application Menu *
echo * *
echo ***************************************
echo.
echo 1 - Datamart and File Status Checking
echo 2 - Log Error Checking
echo.
echo.
::command to call different bat
set /p "cmd=Enter the command [Q > Exit]:"
IF %cmd% EQU 1 (
call "F:\project_DOS command\batch - Status checking.bat"
) ELSE (
IF %cmd% EQU 2 (
call "F:\project_DOS command\batch - Log error checking.bat"
) ELSE (
IF %cmd% EQU Q (
Exit
) ELSE (
echo Wrong Command
)))
pause
________________________________________________________________
@echo off
CLS
Title Error checking
call:checkerror "F:\project_DOS command\error(201509).log" test
::report layout
echo.
echo ***********************************
echo * *
echo * Error Checking *
echo * *
echo ***********************************
echo.
echo file name Error count
echo _____________________________________________
echo error(201509).txt %error_cnt_test%
echo.
echo.
::report layout
::command to call different bat
set /p "cmd=Enter the (0 to menu ; Q to Quit):
IF %cmd% EQU 0 (
call "F:\project_DOS command\Menu.bat"
) ELSE (
IF %cmd% EQU Q (
Exit
) ELSE (
call "F:\project_DOS command\batch - Log error checking.bat"
))
pause
::Funciton Declare
:checkerror
set "file=%~1"
set /a cnt=0
for /f %%a in ('type "%file%"^|find /I /c "error"') do set /a error_cnt_%2=%%a
27/09/2015
[D3.js]Bar chart
var dataset = [];
for (var i=0; i < 15; i++) {
var newnumber = Math.floor(Math.random() * 30) + 5;
dataset.push(newnumber);
}
var w = 500;
var h = 500;
var barPadding = 1;
var svg = d3.select("body")
.append("svg")
.attr("width",w)
.attr("height",h);
var rect = svg.selectAll("rect")
.data(dataset)
.enter()
.append("rect")
.attr({ //multivalue map
x: function(d,i){return i* ( w / dataset.length);},
y: function(d){return (h - d* 10);},
width: (w / dataset.length - barPadding),
height: function(d){return (d * 10);},
fill: function(d){return "rgb(0,0," + ( d * 10) + ")"},
});
var text = svg.selectAll("text")
.data(dataset)
.enter()
.append("text")
.text(function (d){
return d;
})
.attr({ //multivalue map
x: function(d,i){return i* ( w / dataset.length) + 15;},
y: function(d){return (h - d* 10) + 20;},
width: (w / dataset.length - barPadding),
height: function(d){return (d * 10);},
fill: "white",
"font-size": "15px",
"text-anchor": "middle",
});
[D3.js]SVG code
<svg width="500" height="500">
<circle cx="150" cy="150" r="100" class="dancircle"/>
<text x="300" y="250">Circle</text>
</svg>
<circle cx="150" cy="150" r="100" class="dancircle"/>
<text x="300" y="250">Circle</text>
</svg>
26/09/2015
[D3.js]HTML +CSS +Javascript +D3 Basic coding
<!DOCTYPE html>
<html lang="en">
<head>
<!--Call D3-->
<meta charset="utf-8">
<script type="text/javascript" src="d3/d3.js">
</script>
<title></title>
<!--Call CSS-->
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
<body>
<!--Call JS-->
<script type="text/javascript" src="myscript.js"></script>
</body>
</html>
<html lang="en">
<head>
<!--Call D3-->
<meta charset="utf-8">
<script type="text/javascript" src="d3/d3.js">
</script>
<title></title>
<!--Call CSS-->
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
<body>
<!--Call JS-->
<script type="text/javascript" src="myscript.js"></script>
</body>
</html>
13/09/2015
06/09/2015
[SAS]Create dummy variables
data b;
set a;
dummuy_a = (a="Y");
/*if a = Y then dummy_a = 1 else dummy_a =0*/
run;
set a;
dummuy_a = (a="Y");
/*if a = Y then dummy_a = 1 else dummy_a =0*/
run;
Subscribe to:
Posts (Atom)
