Modifying a CoBlocks Filter in Functions

I’m trying to modify slidestoshow parameter in CoBlocks Carousel block via my theme’s functions. Everything in the Codex implies modifying/passing the variable but looking at the code, it appears it’s an [anonymous function?] Forgive me if this term is incorrect.

I’ve tried both apply_filters() and add_filters() to replace the entire array rather than the individual key/value. I’ve tried removing the existing filter and adding it again but I’m not sure if the way it’s coded is preventing me from making my modification.

Do I need to call the plugin Class CoBlocks_Settings?

Here is the original plugin code:

$  block_content = sprintf( '<div class="%1$  s"><div class="coblocks-slick pb-8" data-slick="%2$  s">',     esc_attr( $  class ),     esc_attr(         wp_json_encode(             /**              * Filter the slick slider carousel settings              *              * @var array Slick slider settings.             */             (array) apply_filters(                 'coblocks_post_carousel_settings',                     array(                     'slidesToScroll' => 1,                     'arrow'          => true,                     'slidesToShow'   => $  attributes['columns'],                     'infinite'       => true,                     'adaptiveHeight' => false,                     'draggable'      => true,                     'responsive'     => array(                         array(                             'breakpoint' => 1024,                             'settings'   => array(                                 'slidesToShow' => 3,                             ),                         ),                         array(                             'breakpoint' => 600,                             'settings'   => array(                                 'slidesToShow' => 2,                             ),                         ),                         array(                             'breakpoint' => 480,                             'settings'   => array(                                 'slidesToShow' => 1,                             ),                         ),                     ),                 )             )         )     ) ); 

First, I tried just overriding it with:

apply_filters( 'coblocks_post_carousel_settings',  array( ... )); 

Second, here’s where I’m at in Functions:

apply_filters( 'coblocks_post_carousel_settings', 'my_filter_coblocks_carousel' ); function my_filter_coblocks_carousel() {     $  carousel = array(         'slidesToScroll' => 1,         'arrow'          => true,         'slidesToShow'   => $  attributes['columns'],         'infinite'       => true,         'adaptiveHeight' => false,         'draggable'      => true,         'responsive'     => array(             array(                 'breakpoint' => 1024,                 'settings'   => array(                     'slidesToShow' => 4,                 ),             ),             array(                 'breakpoint' => 600,                 'settings'   => array(                     'slidesToShow' => 4,                 ),             ),             array(                 'breakpoint' => 480,                 'settings'   => array(                     'slidesToShow' => 4,                 ),             ),         ),     );     return $  carousel; }  

Call procedure inside procedure using dynamic sql modifying the parameters getting passed

I have to call a procedure inside a procedure and replace all single quotes inside the parameter to double quotes. Ex: When i call my original proc begin data(10,’"push’s the data"’);end; It throws error due to single quote and i cannot change the string manually at runtime by adding double quote like push”s. I tried replacing inside procedure but probably because the string is passed first it wont take changes.

I wish to call this procedure inside another and using maybe dynamic sql replace single quotes with double.

Something like this:

create procedure dynamic_proc begin execute immediate ‘begin data(id,’||’replace(string,CHR39,CHR39||CHR39)’ AS string)’||’ end;’ end;

So basically the parameter string which is being passed in procedure data needs to have all single quote replace with double at run time.

The PostgreSQL database cannot start after modifying the IP

The following is the operation process:

[root@freelab ~]# su - postgres Last login: Sat Jul  4 10:16:58 EDT 2020 on pts/1 -bash-4.2$   /usr/pgsql-12/bin/pg_ctl -D /postgres -l logfile start waiting for server to start.... stopped waiting pg_ctl: could not start server Examine the log output. -bash-4.2$   -bash-4.2$   date Sat Jul  4 10:35:13 EDT 2020 

But the log does not seem to be updated accordingly

[root@freelab log]# tail -f postgresql-Sat.log 2020-07-04 09:23:14.930 EDT [1832] LOG:  background worker "logical replication launcher" (PID 1840) exited with exit code 1 2020-07-04 09:23:14.930 EDT [1835] LOG:  shutting down 2020-07-04 09:23:14.943 EDT [1832] LOG:  received SIGHUP, reloading configuration files 2020-07-04 09:23:14.943 EDT [1832] LOG:  parameter "data_directory" cannot be changed without restarting the server 2020-07-04 09:23:14.944 EDT [1832] LOG:  configuration file "/postgres/postgresql.conf" contains errors; unaffected changes were applied 2020-07-04 09:23:15.052 EDT [1832] LOG:  database system is shut down 

Efficiently storing and modifying a reorderable data structure in a database

I’m trying to create a list curation web app. One thing that’s important to me is being able to drag-and-drop reorder items in the list easily. At first I thought I could just store the order of each item, but with the reordering requirements, that would mean renumbering everything with a higher order (down the list) than the place where you removed or where you inserted the moved item. So I started looking at data structures that were friendly to reordering, or to both deletion and insertion. I’m looking at binary trees, probably red-black trees or something like that. I feel like I could with great effort probably implement the algorithms for manipulating those.

So here’s my actual question. All the tree tutorials assume you’re creating these trees in memory, usually through instantiating a simple Node class or whatever. But I’m going to be using a database to persist these structures, right? So one issue is how do I represent this data, which is kind of a broad question, sure. I would like to not have to read the whole tree from the database to update the order of one item in the list. But then again if I have to modify a lot of nodes that are stored as separate documents, that’s going to be expensive too, even if I have an index on the relevant fields, right? Like, every time I need to manipulate a node I need to actually find it in the database first, I think.

Also, I obviously need the content and order of each node on the front end in order to display the list, but do I need the client to know the whole tree structure in order to be able to send updates to the server, or can I just send the item id and its new position in the list or something?

I’m sorry if this veers too practical but I thought someone might want to take a crack at it.

Modifying default magnification of Documentation

Well, finally, after decades of Mathematica rendering notebooks incorrectly in Windows, and after many years of Mathematica not supporting high-resolution displays in Windows, finally version 12.1 fixes these problems. Well, almost

Here’s the fly in the ointment: Now the fonts chosen in the documentation are too big: They’re using 14-point fonts for default text, which is ridiculously large. This is probably because in the bad old days, before 12.1, Mathematica would render fonts too small (by a factor of 72/96), so the good folks at Wolfram simply upped the font size to make the documentation readable. Which means that now, with fonts suddenly rendered correctly, that size is too large. So, how to fix this?

The easiest solution I can see (short of waiting another 25 years for Wolfram to get those damn font sizes right…) would be to have Mathematica render all of the documentation at a magnification of 0.75, say. So here is my question:

Is it possible to force Mathematica to display all of the notebooks for its documentation at a 0.75 magnification? I figured out that those notebooks use the style sheet “Reference.nb” which I could edit, in principle (after copying it into my user folder hierarchy). I’m just not sure if it is possible to define the magnification of a notebook as a whole in its style sheet, and if so how to do it. I could of course change the magnification for each of the various kinds of cells that are described in Reference.nb, but that’s a ton of work, and who knows what I might break by doing so.

Can this be done?

Modifying host file versus firewall

I am trying to protect a macOS computer. Specifically, I want to prevent the machine from making unwanted connections over the internet. I am aware of firewalls of course. But I stumbled upon the idea of adding many domain names to /etc/hosts, and redirect them to 0.0.0.0 to prevent connections to them.

Is this method safe? I can see it does not prevent connecting directly to an IP. Would most malware be fooled by such a hosts configuration, or would they likely use directly an IP address, or not honour the /hosts file?

How should I compare using a firewall versus using the /etc/hosts file? I guess the most low level, the harder it is for malware to get around. So which method is lowest level?

Modifying insert and remove functions of an AVL tree so that nodes that don’t need to be rebalanced are not checked for balance

Trying to modify an insert and remove function for an AVL Tree so that no nodes are checked for balance that do not need to be. The suggested way to do was was to change the return types of insert, remove and balance, so that they return information about whether more balance checking is needed. In the case of insert, we know that after one node is rebalanced, no other node will need rebalancing. We can let balance(t) return true if the node t was rebalanced and false otherwise. Then insert should also return a bool value to notify nodes further up the tree that no more rebalancing is required.

 void insert( const Comparable & x, AvlNode * & t )     {         if( t == nullptr )             t = new AvlNode{ x, nullptr, nullptr };         else if( x < t->element )             insert( x, t->left );         else if( t->element < x )             insert( x, t->right );          balance( t );     }  void remove( const Comparable & x, AvlNode * & t )     {         if( t == nullptr )             return;   // Item not found; do nothing          if( x < t->element )             remove( x, t->left );         else if( t->element < x )             remove( x, t->right );         else if( t->left != nullptr && t->right != nullptr ) // Two children         {             t->element = findMin( t->right )->element;             remove( t->element, t->right );         }         else         {             AvlNode *oldNode = t;             t = ( t->left != nullptr ) ? t->left : t->right;             delete oldNode;         }          balance( t );     }   void balance( AvlNode * & t )     {         if( t == nullptr ) return;          cout << "balancing <" << height(t->left) << "> " << t->element << " <" << height(t->right) << ">" << endl ;          if( height( t->left ) - height( t->right ) > ALLOWED_IMBALANCE )             if( height( t->left->left ) >= height( t->left->right ) )                 rotateWithLeftChild( t );             else                 doubleWithLeftChild( t );         else         if( height( t->right ) - height( t->left ) > ALLOWED_IMBALANCE )             if( height( t->right->right ) >= height( t->right->left ) )                 rotateWithRightChild( t );             else                 doubleWithRightChild( t );          t->height = max( height( t->left ), height( t->right ) ) + 1;     }  

I am stuck on how to do this. Would I be adding “return true” after any of the following calls: rotateWithLeftChild( t ), doubleWithLeftChild( t), rotateWithRightChild( t ), doubleWithRightChild( t ) and false otherwise? If someone could point me towards the right direction, it would be appreciated

Anaconda installation modifying .bash_profile on Mac OS X

I installed Anaconda on my Mac (Mojave) and now whenever I start a shell it automatically activates the conda environment. This was totally fine until I realized some of the commands in my .bashrc were not being executed on startup. In particular, I had increased HISTSIZE and HISTFILESIZE but they always seemed to be stuck at their default values of 500. After some googling, I learnt that because of my anaconda installation, it was my .bash_profile that was being used on startup and not .bashrc. This is what my .bash_profile looks like (see below), just adding commands from my .bashrc file (e.g., HISTFILESIZE=100000) to the top of my .bash_profile appears to do nothing. Any suggestions on what I am doing wrong? Thanks!

# Setting PATH for Python 3.7 # The original version is saved in .bash_profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:$  {PATH}" export PATH # added by Anaconda3 2019.07 installer # >>> conda init >>> # !! Contents within this block are managed by 'conda init' !! __conda_setup="$  (CONDA_REPORT_ERRORS=false '/anaconda3/bin/conda' shell.bash hook 2> /dev/null)" if [ $  ? -eq 0 ]; then     \eval "$  __conda_setup" else     if [ -f "/anaconda3/etc/profile.d/conda.sh" ]; then # . "/anaconda3/etc/profile.d/conda.sh"  # commented out by conda initialize         CONDA_CHANGEPS1=false conda activate base     else         \export PATH="/anaconda3/bin:$  PATH"     fi fi unset __conda_setup # <<< conda init <<<  # >>> conda initialize >>> # !! Contents within this block are managed by 'conda init' !! __conda_setup="$  ('//anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)" if [ $  ? -eq 0 ]; then     eval "$  __conda_setup" else     if [ -f "//anaconda3/etc/profile.d/conda.sh" ]; then         . "//anaconda3/etc/profile.d/conda.sh"     else         export PATH="//anaconda3/bin:$  PATH"     fi fi unset __conda_setup # <<< conda initialize <<< 

Modifying WebPartPage in SharePoint Online changes ContentType property

I am using the SharePoint Online CSOM library to change an ImageLink property in a WebPartPage. I first check-out the page, make any changes, and then check-in the page. When I check-in the page, the page’s content type shown in SharePoint Online changes from “Web Part Page” to “Wiki Page”. If I re-read the page, the ListItem’s ContentType field is indeed set to a Wiki page ID (“0x0101080091497901794A9E4E8282666A11DAE0AD”). I’m stumped as to what is causing this.

Here’s my C# code:

using (SP.ClientContext context = SharePoint.GetClientContext(site.Url, siteCollection)) {     string serverRelativeUrl = site.GetServerRelativeUrl(url);     SP.File csomFile = context.Web.GetFileByServerRelativeUrl(serverRelativeUrl);     context.Load(csomFile);     context.ExecuteQueryWithRetry();      LimitedWebPartManager limitedWebPartManager = csomFile.GetLimitedWebPartManager(PersonalizationScope.Shared);     context.Load(limitedWebPartManager);     WebPartDefinitionCollection webPartDefinitionCollection = limitedWebPartManager.WebParts;     context.Load(webPartDefinitionCollection, wpdc => wpdc.Include(         wpd => wpd.Id,         wpd => wpd.WebPart,         wpd => wpd.WebPart.Properties));     context.ExecuteQueryWithRetry();      bool pageChanged = false;     bool webPartChanged = false;     foreach (WebPartDefinition wpd in webPartDefinitionCollection)     {         string imageLinkUrl = wpd.WebPart.Properties.GetField<string>(@"ImageLink");         if (!String.IsNullOrEmpty(imageLinkUrl))         {             bool linkChanged = LinkHandler(ref imageLinkUrl);             if (linkChanged)             {                 wpd.WebPart.Properties[@"ImageLink"] = imageLinkUrl;                 webPartChanged = true;             }         }          if (webPartChanged)         {             wpd.SaveWebPartChanges();             pageChanged = true;         }     }      if (pageChanged)     {         context.ExecuteQueryWithRetry();     } }