2015-02-17

RegEx - Specific string/character count in javascript

// This returns 1
'aasdf'.match(/a+/g).length;

// This returns 2
'aasdf'.match(/a/g).length;

2015-01-05

LINUX - How to mount an apple hard drive in read-write mode

sudo apt-get install hfsprogs
sudo mount -t hfsplus -o remount,force,rw /CURRENT_READ_MOUNT/LOCATION_HERE


LINUX - How to retrieve the group a given username belongs to

groups USERNAME_HERE

2014-12-29

VBA - Excel web service call through XMLHttp

You will need a reference to the library "Microsoft XML, v6.0".


Sub getWebServiceX()

    Dim req As New MSXML2.XMLHttp

    req.Open _
        "GET" _
        , "http://www.webservicex.com/stockquote.asmx/GetQuote?symbol=GOOG" _
        , False
        
    req.send
    MsgBox req.responseText

End Sub

VBA - XMLHttp.open access is denied

If you get an access denied error, then your windows/internet explorer security settings might not be letting you access the URL being requested pro grammatically.


  • Use the URL over HTTPS if available (change the URL from http:// to https://).
  • Relax your security settings.


2014-11-08

TSQL - Integer Percentiles

select
       T1.Field1

       , PERCENT_RANK()
              over( order by Field1 asc ) as PercentRank

       , cast(
              round(
                     PERCENT_RANK()
                           over( order by Field1 asc )
                     * 100
                     , 0
              )
              as int
       ) as PercentRankInt
from
       (
                             select 1 as Field1
              union all select 1
              union all select 1
              union all select 2
              union all select 2
              union all select 3
              union all select 4
              --union all select 8
       ) as T1
order by
       Field1
; 



PercentRankInt calculates the percentile each value occupies in relation to all other values in the column, as an integer number, ready to be used for quick filters, thus enabling the exclusion of, for example, top and bottom deciles, quintiles, etc.

2014-09-18

TSQL - MSDTC on server is unavailable.

Go to "Services", and start the "Distributed Transaction Coordinator" service.