My Note on Solutions.

Friday, March 27, 2015

C# TPL some basic code

Fast win pattern, you might query several urls for the same info, which one return first , that one will be the winner.
image

Send in parallel and join together.
image
long running and cancellable task, if get canceld, try compensate it

image

Thursday, March 12, 2015

Vagrant, Proxy issue, centos local repo and ad-hoc testing

Vagrant is a good VM automation tool for both developers and devops, here are some basic tips that I found useful

Proxy
   if you are stand behind a proxy, you can install one vagran proxy module. the module will setup the proxy on guest machines, like yum.conf, http_proxy variable etc.
here is the plugin https://github.com/tmatilai/vagrant-proxyconf

image

 

when you boot up the vm, you can see the proxy setting applied depends on your OS type

image

Yum Repo.
   you might have one local repo in the company, you can either build all boxes internally which already assign the repo url to local. or just copy one repo to override the system one by using the provisioning scripts.

image

image

and in your local file, change the ip to internal one

image

Provision scripts to check whether package installed or not. using rpm to query package or use command to determine whether a command exists

image

Thursday, February 19, 2015

Opencart fix, show the shipping method in orders admin page and filter by shippingmethod

it turns that this should be a common feature for opencart admins, basically the operation team would like to see orders with priority shipping method and process those orders first. on 1.5, no way you can see this at once. basically the orders page looks like this by default

image

they actually want to see the UI like this, with shipping method on the overview

image

even more, they want a filter to see all orders with priority shipping selected.

image

To fix this, pretty straight forward. change the orders module/controller/template file, to include shippingmethod in the data query back. and add a filter logic to narrow down records.

I have a patch file, email me if you are interested. click about me on the page to get my email

Wednesday, February 11, 2015

C# merge sorting vs insert sorting

Quick test for a 50K random double array with random order, to soft it using the system libarry  and my own insert sorting/ merge sorting, the time takes to do the soring is quite different.

given a array with size 50K of  double values,

image

if increase to 100K, more time for insertion sorting

image

 

https://github.com/ryandh/CSharpSortingInsertedMerged/blob/master/Program.cs

Friday, February 6, 2015

Jquery , Simple plugin with default options

check this sample fiddler, http://jsfiddle.net/androidyou/dox5x8pp/

basically, we can use the $.extend to assign a default value if options are not assigned.

image

if you put default option,

image

image

Wednesday, January 7, 2015

DNS troubleshooting tools and tips - nslookp

if you are on Windows, dig is not there, you can do most DNS query through nslookup.

to see the DNS cache on your local server,  run “ipconfig /displayDNS”

image

same thing, ipconfig /flushDNS to purge the cache.

to see name server of a giving domain

image

to see all infomration like root server, try nslookup , set all

image

to see mx record of amazon.

image

to see the spf record?

image

what about debug information

image

to see all information

image

to see all the ips of a domain or even this history.

https://www.virustotal.com/en/domain/dl.dropbox.com/information/

image

DNS troubleshooting tools and tips - dig

To see top level Name Servers,  dig –t ns com

image

If we want to see what’s are the name server of Google by asking any top level com servers.

image

now we can ask any nameserver of google, what’s are the ip of www.google.com

image

we can also using host command to get the ip or alias information

image

we can see the alias gmail.google.com

image

if we want to see some debug information. we can put debug there

[~]dig +trace  -t mx  dropbox.com

; <<>> DiG 9.8.3-P1 <<>> +trace -t mx dropbox.com
;; global options: +cmd
.            15634    IN    NS    a.root-servers.net.
.            15634    IN    NS    b.root-servers.net.
.            15634    IN    NS    c.root-servers.net.
.            15634    IN    NS    d.root-servers.net.
.            15634    IN    NS    e.root-servers.net.
.            15634    IN    NS    f.root-servers.net.
.            15634    IN    NS    g.root-servers.net.
.            15634    IN    NS    h.root-servers.net.
.            15634    IN    NS    i.root-servers.net.
.            15634    IN    NS    j.root-servers.net.
.            15634    IN    NS    k.root-servers.net.
.            15634    IN    NS    l.root-servers.net.
.            15634    IN    NS    m.root-servers.net.
;; Received 228 bytes from 8.8.8.8#53(8.8.8.8) in 29 ms

com.            172800    IN    NS    a.gtld-servers.net.
com.            172800    IN    NS    b.gtld-servers.net.
com.            172800    IN    NS    c.gtld-servers.net.
com.            172800    IN    NS    d.gtld-servers.net.
com.            172800    IN    NS    e.gtld-servers.net.
com.            172800    IN    NS    f.gtld-servers.net.
com.            172800    IN    NS    g.gtld-servers.net.
com.            172800    IN    NS    h.gtld-servers.net.
com.            172800    IN    NS    i.gtld-servers.net.
com.            172800    IN    NS    j.gtld-servers.net.
com.            172800    IN    NS    k.gtld-servers.net.
com.            172800    IN    NS    l.gtld-servers.net.
com.            172800    IN    NS    m.gtld-servers.net.
;; Received 489 bytes from 128.63.2.53#53(128.63.2.53) in 144 ms

dropbox.com.        172800    IN    NS    ns-564.awsdns-06.net.
dropbox.com.        172800    IN    NS    ns-315.awsdns-39.com.
dropbox.com.        172800    IN    NS    ns-1162.awsdns-17.org.
dropbox.com.        172800    IN    NS    ns-1949.awsdns-51.co.uk.
;; Received 198 bytes from 192.52.178.30#53(192.52.178.30) in 167 ms

dropbox.com.        3600    IN    MX    1 aspmx.l.google.com.
dropbox.com.        3600    IN    MX    10 aspmx2.googlemail.com.
dropbox.com.        3600    IN    MX    10 aspmx3.googlemail.com.
dropbox.com.        3600    IN    MX    5 alt1.aspmx.l.google.com.
dropbox.com.        3600    IN    MX    5 alt2.aspmx.l.google.com.
dropbox.com.        172800    IN    NS    ns-1162.awsdns-17.org.
dropbox.com.        172800    IN    NS    ns-1949.awsdns-51.co.uk.
dropbox.com.        172800    IN    NS    ns-315.awsdns-39.com.
dropbox.com.        172800    IN    NS    ns-564.awsdns-06.net.
;; Received 296 bytes from 205.251.194.52#53(205.251.194.52) in 21 ms

image
 
Locations of visitors to this page