Friday, August 24, 2018

Meteor error on update

I'm getting this error when I upgrade my meteor app to the latest version (1.2)

Exception in callback of async function: Error: url must be absolute and start with http:// or https://

My meteor packages

blaze-html-templates 1.0.1 Compile HTML templates into reactive UI with Meteor Blaze

check 1.1.0 Check whether a value matches a pattern

d3 1.0.0 Library for manipulating documents based on data

ejson 1.0.7 Extended and Extensible JSON library

fortawesome:fontawesome 4.4.0_1 Font Awesome (official): 500+ scalable vector icons, customizable via CSS, Retina friendly

fourseven:scss 3.4.1 Style with attitude. Sass and SCSS support for Meteor.js (with autoprefixer and sourcemaps).

http 1.1.1 Make HTTP calls to remote servers

insecure 1.0.4 (For prototyping only) Allow all database writes from the client jquery 1.11.4 Manipulate the DOM using CSS selectors

logging 1.0.8 Logging facility.

meteor-base 1.0.1 Packages that every Meteor app needs

mobile-experience 1.0.1 Packages for a great mobile user experience

mongo 1.1.3 Adaptor for using MongoDB and Minimongo over DDP

pauloborges:mapbox 2.1.5 Mapbox.js for Meteor apps

random 1.0.5 Random number generator and utilities

react 0.14.1_1 Everything you need to use React with Meteor.

reactive-var 1.0.6 Reactive variable

reactrouter:react-router 0.1.12 react-router (official): A complete routing solution for React.js

reload 1.1.4 Reload the page while preserving application state.

session 1.1.1 Session variable

spacebars 1.0.7 Handlebars-like template language for Meteor

standard-minifiers 1.0.2 Standard minifiers used with Meteor apps by default. tracker 1.0.9 Dependency tracker to allow reactive callbacks

any solution?

Monday, August 20, 2018

Comparing DateTime from cell with two dates VBA

I am trying to compare the dates with time from inside a cell with Now()

I have the code so the style sheet autorefresh itself so when first date with time is overdue cell go green and when the second date and time is overdue the cell would go red.

I can only get this to work comparing the date without the time with DateValue.

There is a colunm with cells with two dates with times mayorly (sometimes there is only 1 date and sometimes there is only one date without time)

Cells with two dates with time would be as the example below.

-----------------
12/11/2011 09:00
13/11/2011 15:00
-----------------

This is what I have so far after several attempts (cosidering that many of the attemps have been deleted already)

Sub Worksheet_Change()

 Set aWorkBook = Workbooks("Workbook.xls").Sheets("sheet 2").Range("C3:C10")


    For Each Cell In aWorkBook
    'MsgBox (Mid(Cell.Value, 1, 19))
    If Cell.Value <> "" Then
    MsgBox (Now < Mid(Cell.Value, 11, 6))
    'MsgBox ((Mid(Cell.Value, 1, 17)) < Now())
    'MsgBox ((Cell.Value))

        If (CDate(Mid(Cell.Value, 1, 17)) < Now()) Then
              'MsgBox ("Hello")
              'Cell.Interior.ColorIndex = 3
          End If

       End If
    Next
End Sub

In this case I am using msgbox to test outcome but not success.

Any help would be very much appreciated.

Solved

Looking at your code it apears the date/time values are strings. If thats the case use

(DateValue(Cell) + TimeValue(Cell)) > Now()

If cells contain values formatted as dates, use

Cell > Now()

You might be better off using Conditional Formatting rather than the _Change event. Eg to format cell A3 use conditional formula (note, no $'s)

(DateValue(A3) + TimeValue(A3)) > Now()

then copy paste formats to any other cells you want


Sunday, August 19, 2018

Batch-correct incorrectly formatted XML files

I have 300+ XML files that look like this:


  Mathematics 
  
    Geometry 
    
Coordinate Geometry Plotting Ordered Pairs // Lots of content
(eof)

It SHOULD read like so:


  Mathematics


  Geometry

Coordinate Geometry
Plotting Ordered Pairs // Lots of content

Does there exist there a batch solution to correct this?

Solved

The Saxon XSLT processor allows you to specify a directory containing source documents on the input line:

java net.sf.saxon.Transform -t -s:inputdir -o:outputdir -xsl:theAbove.xslt

which has the advantage that all the initialisation cost (like compiling the stylesheet) is only incurred once.


The easiest way is to use an XSLT processor (like xsltproc for Linux). You have to surround your input XML with a root element for the XML to be valid.

Then use this XSLT-1.0 file (theAbove.xslt) for transforming your XML.





  

  
    
  

  
    
      
      
    
    
  


Output:


    Mathematics


    Geometry

Coordinate Geometry
Plotting Ordered Pairs

Call it with

xsltproc theAbove.xslt yourSource.xml

It is possible to use two Perl regular expression replaces, second one with marking groups and back-references, to reformat the header area of your XML files from


  Mathematics 
  
    Geometry 
    
Coordinate Geometry Plotting Ordered Pairs // Lots of content

to


  Mathematics


  Geometry

Coordinate Geometry
Plotting Ordered Pairs // Lots of content

So the block with lots of content is not unindented, but the other lines are as wanted on running this batch file from within the directory containing the *.xml files. Windows command interpreter cmd.exe does not support Perl regular expression replaces in text files. For that reason is needed additionally JREPL.BAT written by Dave Benham which is a batch file / JScript hybrid for reformatting the lines in the XML files using regular expression replaces. JREPL.BAT must be in same directory as this batch file.

@echo off
if not exist *.xml goto :EOF
if not exist "%~dp0jrepl.bat" goto :EOF

for /F "delims=" %%I in ('dir *.xml /A-D /B') do (
    call "%~dp0jrepl.bat" "^[\t ]*[\t ]*\r?\n" "" /M /F "%%I" /O -
    call "%~dp0jrepl.bat" "^[\t ]*<(AREA|SECTION|SUBJECT|TOPIC)(.*>)[\t ]*(\r?\n)[\t ]*(.*)[\t ]*$" "<$1$2$3  $4$3" /M /F "%%I" /O -
)

For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.

  • call /?
  • dir /?
  • echo /?
  • for /?
  • goto /?
  • if /?
  • jrepl.bat /?

Saturday, August 18, 2018

Call res callback in Express in addition to callback data

I have this code in my express controller file:

function logResponse(err, data) {
  if (err)
  {
    console.log('error name %s', err.name);
    console.log('error message %s', err);
  }

  console.log('\ndata: %s', JSON.stringify(data));

  res.status(200).send({
    'status'     : 'OK',
    'type'       : 'success',
    'message'    : 'User Info successfully fetched.',
    'data'       : JSON.stringify(data)
  });
}

// Get User Info through external API
exports.index = function(req, res) {
  privateClient.getUserInfo(logResponse, 'meMyselfAndIrene');
};

I get this to be expected error:

res.status(200).send({
     ^

TypeError: Cannot read property 'status' of undefined 

How do I define things in order for res to be available in logResponse? And how can I chain the callbacks in order to split up logging and http responding?

Solved

Simply passing as callback

function (err, data) { logResponse(err, res, data); }

will redirect res appropiately.