This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ctx = stream_context_create(['ssl' => [ | |
'verify_peer' => false, | |
'verify_peer_name' => false | |
]]); | |
$html = file_get_contents('https://google.com/', FALSE, $ctx); | |
$meta = stream_context_get_options($ctx)['ssl']['session_meta']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(RPostgreSQL) | |
library(RODBC) | |
pg.conn <- function(set){ | |
conn <- dbConnect(PostgreSQL(), host=set$host, user=set$user, password=set$pwd, dbname=set$dbname) | |
list( | |
query = function(sql,params=c()) { | |
for(i in 1:length(params)){ | |
sql <- gsub( paste("\\$",i,sep="") , paste("'",params[i],"'",sep="") , sql ) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require("request"), | |
fs = require("fs"); | |
var options = { | |
url: 'https://zh.wikipedia.org/w/api.php?format=json&action=parse&pageid=13', | |
headers: { | |
'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36', | |
'Cookie' : 'TBLkisOn=0; CP=H2; WMF-Last-Access=11-Jan-2016; GeoIP=:::::v6', | |
'Accept-Language' : 'zh-TW,zh;q=0.8,en-US;q=0.6,en;q=0.4' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
try { | |
$db = new PDO("sqlsrv:server=localhost;Database=rec-booklife","zap","123"); | |
$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); | |
} catch( PDOException $e ) { | |
die( "Error connecting to SQL Server:".$e ); | |
} | |
$stmt = $db->prepare("select top 100 oid,cname from book"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
echo Load tar... | |
.\docker.exe load < %1% | |
echo Run Image... | |
.\docker.exe run -d -p 9876:80 -p 5433:5432 --name=FBI fbi:v13 | |
pause |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Progress{ | |
private $max; | |
private $value; | |
private $length = 10; | |
private $style = "="; | |
/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE INDEX object_title ON object(cname); | |
CLUSTER object using object_title; | |
---------------------------------------- | |
CREATE INDEX vd_ptt_post_origin ON vd_ptt_post(origin); | |
CLUSTER vd_ptt_post using vd_ptt_post_origin; | |
---------------------------------------- | |
CREATE INDEX vd_ptt_post_oid ON vd_ptt_post(oid); | |
CLUSTER vd_ptt_post using vd_ptt_post_oid; | |
---------------------------------------- | |
CREATE INDEX vd_ptt_post_count ON vd_ptt_post(count); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
URL=$1 | |
[[ $URL =~ (node-v5\.8\.0-.*)\.tar\.gz$ ]] && TARFile=${BASH_REMATCH[0]} && DirName=${BASH_REMATCH[1]} | |
[[ $TARFile == "" ]] && echo "url is wrong" && exit | |
NodeJSPath=$(/sbin/getcfg nodejs Install_Path -f /etc/config/qpkg.conf) | |
wget --no-check-certificate $URL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear | |
close all | |
% Generate data | |
sample_size = 200; | |
A=repmat([2,2], sample_size,1)+randn(sample_size, 2); | |
B=repmat([-2,-2],sample_size,1)+randn(sample_size, 2); | |
X=[A; B]; | |
Y=[ones(sample_size,1); -ones(sample_size,1)]; | |
figure, plot(A(:,1),A(:,2),'ro'), hold on, plot(B(:,1),B(:,2),'xb'); | |
pause; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION search_engine(_words varchar) | |
RETURNS table (oid int) AS | |
$BODY$ | |
declare _words_len int;_arrwords varchar[]; | |
begin | |
select regexp_split_to_array(_words,'[ ,-.~\+]+') into _arrwords; | |
select array_length(_arrwords,1) into _words_len; | |
return query | |
select d.oid from token t,dupindex d,vd_ptt_post p | |
where t.words in (select unnest(_arrwords)) |