Google ChartWrapper bar formatted table

The end result is a bar formatted table chart that has expanding and minimising rows.

The code below works fine but I’d like to know if there is a cleaner way to achieve the same result (see JSFiddle for working example).

In the production version, the datatable & the “parent” rows (for want of a better term) will be defined at run time, hence asking if there is a better way to do it.

Points to note, I’m very much an ok-ish hobbyist coder and my background is much more vb.NET orientated than JS. It took a tonne of google searching and code example plagiarism just to get it to work, so please excuse any school-boy errors.

JSFiddle

HTML:

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <div id="vis_div"></div> 

JavaScript:

// Creates a bar formatted table chart with expanding and retracting rows // DataTable contains ALL the rows to be displayed, "parent" rows are // declared twice.  The first declaration contains the button event that shows the // child rows when clicked.  The second declaration contains the button event that // reduces the visable rows to the parent rows. // Two buttons are required for ease of coding and to show a + on the first  // declaration and a - in the second.  google.charts.load('current', {'packages':['table']}); google.charts.setOnLoadCallback(drawVisualization);   function drawVisualization(iRows) {    var sRows   if (iRows === undefined) {     sRows = [0, 4, 10, 13]   }   else {     sRows = iRows   }    //Create and format the DataTable visualization with bar formatter   //This has to be done outside of the chartWrapper declaration so that   //the bar formatter is applied.  chartWrapper does not allow for formatting   //to be applied to the DataTable  var data = new google.visualization.DataTable();   data.addColumn('string', '+/-');   data.addColumn('string', 'Department');   data.addColumn('number', 'Revenues');   data.addRows([                 ['<button onclick="MaxDraw(0);">+</button>', 'abc', 1000],                 ['<button onclick="MinDraw(0);">-</button>', 'abc', 1000],                 ['', '123', 650],                 ['', '456', 350],                 ['<button onclick="MaxDraw(3);">+</button>', 'def', 10000],                 ['<button onclick="MinDraw(3);">-</button>', 'def', 10000],                 ['', '789', 1000],                 ['', '101', 3000],                 ['', '112', 2000],                 ['', '131', 4000],                 ['<button onclick="MaxDraw(8);">+</button>', 'ghi', 500],                 ['<button onclick="MinDraw(8);">-</button>', 'ghi', 500],                 ['', '415', 500],                 ['<button onclick="MaxDraw(10);">+</button>', 'jkl', 6000],                 ['<button onclick="MinDraw(10);">-</button>', 'jkl', 6000],                 ['', '161', 5500],                 ['', '718', 500]                             ]);      var table = new google.visualization.Table(document.getElementById('vis_div'));      var formatter = new google.visualization.BarFormat({width: 220});     formatter.format(data, 2);     var wrapper = new google.visualization.ChartWrapper({     chartType: 'Table',     dataTable: data,     options: {allowHtml: true},     view: {rows: sRows},      containerId: 'vis_div'   });    wrapper.draw();  }  MaxDraw = function DrawRows(iSelectedRow){    if (iSelectedRow === 0){     drawVisualization([1, 2, 3, 4, 10, 13]);   }   else if (iSelectedRow === 3){     drawVisualization([0, 5, 6, 7, 8, 9, 10, 13]);   }   else if (iSelectedRow === 8){     drawVisualization([0, 4, 11, 12, 13]);   }   else if (iSelectedRow === 10){     drawVisualization([0, 4, 10, 14, 15, 16]);   }   }  MinDraw = function DrawRows(iSelectedRow){     drawVisualization([0, 4, 10, 13]); } 

Can’t see newly created parition (and formatted as ExFat or NTFS) in Bootcamp (Windows 7)

I’m trying to resize my Bootcamp partition and finally shrunk my AFPS partition smaller and formatted the new partition to NTFS (and later to ExFAT) in hope to be able to see it in Windows and merge it with Bootcamp (Since I can’t do it in macOS due to my Boocamp partition being NTFS) but I can’t see it in Windows in any program I try to merge them. I just see Bootcamp partition and one big “Apple” one which in fact should be three.

(I’m Using Mojave)

Thanks

Brand new external hard drive formatted exFAT is mounted read only

I bought a new HDD, formatted as exFAT with mac. I moved files from my laptop to the HDD (moved, I mean, I also deleted them). It happened with a directory it got stucked. I quit the process of copying that directory. I tried to trash and erase trash. I could not erase it. I tried eject from Finder. It could not. I unplugged – when there were no process active.

I tried to plug, and could not mount. I discover apple run fskc automatically. I kill the process, used disktutil to mount the volume, unmount and eject.

I tried to plug and mount and again. Now the volume is mounted, but Read only. S.M.A.R.T. not verified.

So I launch fskc – I don’t know when it will finish, there are (estimated) about million files, HDD is 4T.

I m confident disk is ok, since brand new.

Please advice on how get rid of read-only and steps to mount exFAT external HDD properly in mac, want to prevent automatic fskc – also because fskc is taking forever, and not sure it could repare anything if in read-only mode. FSKC is stucked at checking system hierarchy:

    diskutil list  /dev/disk0    #:                       TYPE NAME                    SIZE       IDENTIFIER    0:      GUID_partition_scheme                        *500.3 GB   disk0    1:                        EFI EFI                     209.7 MB   disk0s1    2:                  Apple_HFS Macintosh HD            499.4 GB   disk0s2    3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3 /dev/disk1    #:                       TYPE NAME                    SIZE       IDENTIFIER    0:      GUID_partition_scheme                        *4.0 TB     disk1    1:                        EFI EFI                     209.7 MB   disk1s1    2:       Microsoft Basic Data myHDD                 4.0 TB     disk1s2    sudo fsck_exfat /dev/disk1s2 fsck_exfat: Opened /dev/rdisk1s2 read-only ** Checking volume. ** Checking main boot region. ** Checking system files. ** Volume name is luigi4T. ** Checking upper case translation table. ** Checking file system hierarchy. 

Mac OS 1.9.5

Python sort csv data and output formatted to txt file

I have a csv file i need to remove duplicate connections

192.168.136.192,2848,100.100.100.212,6667,"other" 100.100.100.212,6667,192.168.136.192,2848,"other" 100.100.100.212,6667,192.168.136.192,2848,"CHAT IRC message" 192.168.61.74,4662,69.192.30.179,80,"other" 192.168.107.87,4662,69.192.30.179,80,"other" 192.168.107.87,4662,69.192.30.179,80,"infection" 192.168.177.85,4662,69.192.30.179,80,"infection" 192.168.177.85,4662,69.192.30.179,80,"other" 192.168.118.168,4662,69.192.30.179,80,"infection" 192.168.118.168,4662,69.192.30.179,80,"other" 192.168.110.111,4662,69.192.30.179,80,"infection" 

192.168.136.192,2848,100.100.100.212,6667,”other” 100.100.100.212,6667,192.168.136.192,2848,”other” are == one needs to be removed 192.168.107.87,4662,69.192.30.179,80,”other” 192.168.107.87,4662,69.192.30.179,80,”infection” are == and other needs to be removed 69.192.30.179,80,192.168.61.74,1079,”other” 192.168.118.168,1079,69.192.30.179,80,”infection” are == and the ‘other” removed

once removed i need a count on the tree different types “other”,”infection,”Cnc” and to output into a txt file |src|srcport|dst|dstport|msg| so far i have removed just the duplicates with

import csv,sys,operator with open(r'alerts.csv','r') as in_file, open('alertsfix.csv','w') as  out_file: seen = set() # set for fast O(1) amortized lookup for line in in_file:     if line in seen: continue # skip duplicate      seen.add(line)     out_file.write(line) 

I am very new to python so any guidance will be greatly appreciated

PhpWord does not print html when using drupal text formatted long field values

I am using phpword library but unable to print html from drupal fields

I followed the html example given here https://github.com/DerekMarcinyshyn/phpword/blob/master/samples/Sample_26_Html.php

            $  W = new \PhpOffice\PhpWord\PhpWord();               $  printWord = new PrintWord($  W);             $  section = $  printWord->phpWord->addSection();             $  printWord->phpWord->addParagraphStyle('Heading2', array('alignment' => 'center'));             $  printWord->phpWord->addSection();             $  html  = $  board_reference->get('field_introduction')->value;         $  html = '<div>ENTERS HERE</div>';  //the below code does not work event field_introduction used in $  html has values  // which is Text (formatted, long) drupal field of type full html                 $  printWord->save($  section,$  html); //but this works                     $  printWord->save($  section,$  html2);      <?php      namespace Drupal\custom_autofill_reference\Controller;     use \PhpOffice\PhpWord;     use \Drupal\node\Entity\Node;      class PrintWord {        public function __construct($  phpWord){         $  this->phpWord = $  phpWord;       }        public function save($  section,$  html){         \PhpOffice\PhpWord\Shared\Html::addHtml($  section,$  html, false, false);         $  this->phpWord->save($  filename, $  format = 'Word2007', $  download = true);       }       } 

Formatted reading

I thought it might be useful if reading could at least sort of mirror writing. For example, if I write some output like:

somefile << "foo: " << foo << ", bar: " << bar; 

…it would be nice if I could read it back in like:

somefile >> "foo: " >> foo >> ", bar: " >> bar; 

So, this code attempts to support that:

#ifndef FMT_READ_H_ #define FMT_READ_H_ #include <cctype> #include <iostream> #include <locale>  template <class charT> std::basic_istream<charT> &operator>>(std::basic_istream<charT> &is, charT const *fmt) {     if (fmt == nullptr)         return is;      if (is.flags() & std::ios_base::skipws) {         std::locale const &loc = is.getloc();         if (std::has_facet<std::ctype<charT>>(loc)) {             auto const &ct = std::use_facet<std::ctype<charT>>(loc);             while (ct.is(std::ctype_base::blank, is.peek()))                 is.ignore(1);         }         else             while (std::isspace(is.peek()))                 is.ignore(1);     }      while (*fmt) {         if (*fmt != is.peek())             is.setstate(std::ios_base::failbit);         ++fmt;         is.ignore(1);     }     return is; }  #endif 

Here’s a little bit of test code:

#include <sstream> #include <iostream> #include "fmt_read.hpp"  int main() {      std::istringstream b("START(0, 0)\nGOAL(1,2)");      int startX, startY;     b >> "START(" >> startX >> "," >> startY >> ")";     std::cout << "start_x: " << startX << ", start_y: " << startY << "\n";      int goalX, goalY;     b >> "GOAL(" >> goalX >> "," >> goalY >> ")";     std::cout << "goal_x: " << goalX << ", goal_y: " << goalY << "\n"; } 

One big question in my mind is about what it does if it finds that the stream has been imbued with locale that doesn’t contain a ctype facet. Right now, in that case it falls back to the global locale–but I’m wondering whether it might be better to treat that as an error instead (but even then, not sure if it should set the failbit, or maybe throw an exception, or…)

How to print text (formatted, long) in twig without raw filter?

We have a text (formatted, long) field that is used to insert embed code such as the Youtube embed code for videos.

When printing the field in twig we are finding that rather than rendering the embed code, it is displaying the embed code as string. To get around this, we currently apply Twig’s Raw filter, but wanted to see if there was a way to not use the raw filter and render the field as is.

Content type (basic page):

  1. body (text, formatted long) field
  2. title

Current results (inserted into Body field using Full HTML text format, displayed as string):

<script type="text/javascript" id="vidyard_embed_code_SkWfXrpFKFpS9JrytJwqMt" src="//play.vidyard.com/SkWfXrpFKFpS9JrytJwqMt.js?v=3.1.1&type=lightbox"></script><div class="outer_vidyard_wrapper"><div class="vidyard_wrapper" onclick="fn_vidyard_SkWfXrpFKFpS9JrytJwqMt();"><img width="360" src="//play.vidyard.com/SkWfXrpFKFpS9JrytJwqMt.jpg?" alt="Generating Leads with Video Content"><div class="vidyard_play_button"><a href="javascript:void(0);"></a></div></div></div> 

Desired results (output of body field shows the video)

Video shown

Firebase – onAuthStateChanged does not return correct formatted object

My app is working correctly until a few minutes ago.

According to documentation, the user object returned will have following properties:

firebase.auth().onAuthStateChanged(function(user) {   if (user) {     var displayName = user.displayName;     var email = user.email;     var emailVerified = user.emailVerified;     var photoURL = user.photoURL;     var isAnonymous = user.isAnonymous;     var uid = user.uid;     var providerData = user.providerData;   } else {     // User is signed out.   } }); 

If I want to access uid, I can just call user.uid.

But the problem is I discovered this behavior is broken while I was developing new features a few minutes ago.

If I want to access properties like uid or email, now I need to access it like this:

user._user.uid or user._user.email

Why does this happened?

Is Firebase doing any update?