Sails.JS’s publish method doesn’t work in a controller, but works in the console

Currently, I’m exploring web development to see what all the hype is about. Except for following a small ‘create your first CRUD app in Node.JS’ and some formal training in JavaScript, I have no experience.

I’m new to JavaScript, NodeJS, Sails.JS, and WebSockets.

My current problem is this:

The app I’m trying to develop receives POST calls with a JSON object. This is the input part of the application. These POST calls originate from any random host.

The output is a webpage that updates itself by listening on a Sails.JS powered WebSocket system called sails.io.js.

Basically, each POST from any host should result in an event on the WebSocket.

Since I’m not building a formal REST API, I have to define some parts myself in Sails.JS. I do have blueprints enabled.

First, in the controller that handles the POST call, I can call the code below so existing WebSockets can receive an event of a new ServiceHeartBeatSession being created. All the server side code mentioned here is located in the controller or executed in the console.

sails.sockets.addRoomMembersToRooms(ServiceHeartBeatSession._classRoom()
, ServiceHeartBeatSession._room(session.id) );

Then, the invoke method is executed to send this event to all listening WebSockets.

ServiceHeartBeatSession.publish(( session.id ), { “verb”: “created” });

However, the .publish method does not result in a event to an existing WebSocket. Unless I execute it myself in the console. The WebSocket is registered like this:

io.socket.on(‘serviceheartbeatsession’, function(resData) {
alert(‘Something changed!!!!’);
});

I did some digging into the sourcecode and made some attempts at debugging this myself. Here’s what I’ve found so far:

Running the .publish call in the console produces the desired result.
It appears that the .addRoomMembersToRooms is a requirement for the .publish to work in the console. So I’m assuming that .addRoomMembersToRooms works as intended.
I tried the alternative below, but that doesn’t work in the controller. However, it does work in the Node console.
sails.sockets.broadcast(( ServiceHeartBeatSession._room(session.id) ), “serviceheartbeatsession”, ‘hi!’);

The following works as intended, but I prefer not to use that.
sails.io.sockets.emit(‘serviceheartbeatsession’, { verb: ‘created’ });

The above attempt lacked a room selection, so I dug a little deeper. The calls below where the result of a .publish method. However, only after repeating this in the console, it worked.

var emitter = sails.io.sockets;
emitter.in(‘sails_model_serviceheartbeatsession_5b6b26748377829d34983d67:serviceheartbeatsession’); // for example
emitter.emit(‘serviceheartbeatsession’, { verb: “created” });

Check more information in the article: https://adevait.com/nodejs/building-nodejs-apis-with-sailsjs
Anyone have any ideas?

 

Navigating to SharePoint using teamslogon.aspx doesn’t work Teams mobile

I want to navigate SharePoint in Teams tab app by clicking button as below, but it doesn’t work properly only in MS Teams Mobile app(works with desktop), it shows the loading screen.

var url= https://${DOMAIN_URL}/_layouts/15/teamslogon.aspx?spfx=true&dest=/${SITE_URL};
window.location.replace( url );

is there any reason for that ?

enter image description here

manifest similar to this

 "staticTabs": (
         {
             "entityId": "16f1325347cb",
             "name": "Portals7",
             "contentUrl": "https://my-site-url.io/Tab?loginHint={loginHint}&userObjectId={userObjectId}&userPrincipalName={userPrincipalName}&tenantId={tid}&locale={locale}&theme={theme}&userPrincipalName={userPrincipalName}",
    
             "websiteUrl": "https://my-site-url.io/Tab",
             
             "scopes": ("personal"),
             "supportedPlatform" : ("desktop")
         }
     ),
   "permissions": (
     "identity",
     "messageTeamMembers"
   ),
   "validDomains": (
   "my-site-url.io",
      
     "*.login.microsoftonline.com",
     "*.sharepoint.com",
     "*.sharepoint-df.com",
     "spoppe-a.akamaihd.net",
     "spoprod-a.akamaihd.net",
     "resourceseng.blob.core.windows.net",
     "msft.spoppe.com"
   ),
   "webApplicationInfo": {
     "id": "00000003-0000-0ff1-ce00-000000000000",
     "resource": "https://{teamSiteDomain}"
   }
 } 

responsive – Mobile Menu Button Doesn’t Appear As Expected On Mobile Devices

I have a menu toggle button for my mobile design (inherited from the Storefront theme), that works fine when I decrease the width of my PC browser window to no more than the max-width of the media query it’s styled within. But when I visit it actually using a phone or tablet, and I’ve tried three different browsers; the text, which is “Meny”, takes up two rows. ‘Men’ on the first row, and a ‘y’ on the second. The width of the element is set to auto, and the max-width to 120px. So it should have room to expand, but it doesn’t. Why does the button render with it’s text on one line in a desktop window, but on two lines on a phone or tablet?

And there is more. The toggle button can be selected with the css selection ‘button.menu-toggle’. And if I put a wider width for it, say width: 120px; the button becomes this length in the desktop browser (Firefox), but on a phone or tablet it doesn’t seem to have any effect. This code looks as follows:

@media (max-width: 768px) {
    button.menu-toggle {
        width: auto;
        max-width: 120px;
        /*width: 120px;*/
    }
}

Even if I set the CSS as inline CSS with JavaScript, the button doesn’t expand on my phone. I have tried to set it like this:

jQuery("button.menu-toggle").css({
/*"width": "auto",*/"max-width":"120px", "width": "100px"
});

You can see it at my website (a work in progress), here: https://www.techsaker.se .

Why does it work as I want it to on a desktop, but not on mobile devices?

oracle – Why doesn’t /*+ NO_INDEX*/ hint , affect the “execution plan”?

I have a sample table with below structure :

create table mi_dimcustomer
(customer_num    number(10),
 <other columns> <data types>)

And there is a unique index on column customer_num. I’m trying to hint the optimizer not to use this index (just for the sake of practice) like this :

select /*+gather_plan_statistics*/ /*+ no_index(t idx1_dimcustomer) */
 *
  from mi_dimcustomer t
 where t.customer_num = 12;

But in the execution plan , I can see that the optimizer is still using the index! This is the way I’m capturing the execution plan :

Step-1)

    select sql_id, child_number, sql_text
      from v$sql
     where sql_text like '%where t.CUSTOMER_NUM = 12%';

Step-2)    

select *
  from table(dbms_xplan.display_cursor('2qataxp9mahpj',
                                       '0',
                                       'ALLSTATS LAST +COST +OUTLINE'))

And you can see the execution plan below:

SQL_ID  2qataxp9mahpj, child number 0
-------------------------------------
select /*+gather_plan_statistics*//*+ NO_INDEX(t idx1_dimcustomer) */ * 
from mi_dimcustomer t where t.CUSTOMER_NUM = 12
 
Plan hash value: 3784660444
 
-----------------------------------------------------------------------------------------------------------------------
| Id  | Operation                   | Name             | Starts | E-Rows | Cost (%CPU)| A-Rows |   A-Time   | Buffers |
-----------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |                  |      1 |        |     2 (100)|      1 |00:00:00.01 |       3 |
|   1 |  TABLE ACCESS BY INDEX ROWID| MI_DIMCUSTOMER   |      1 |      1 |     2   (0)|      1 |00:00:00.01 |       3 |
|*  2 |   INDEX UNIQUE SCAN         | IDX1_DIMCUSTOMER |      1 |      1 |     1   (0)|      1 |00:00:00.01 |       2 |
-----------------------------------------------------------------------------------------------------------------------

Why is this happening?

Thanks in advance

usa – I94 Travel History doesn’t show my departure? Who do I contact?

Please wait for two or three more days and check again. It is very likely to show your departure “in due course” with no action required by you. Meanwhile be sure to retain your boarding card. If after a week there is still no record of your departure see U.S. Customs and Border Protection which includes:

If you departed by a commercial air or sea carrier (airlines or cruise ships), your departure from the U.S. can be independently verified, and it is not necessary to take any further action, although holding on to your outbound (from the U.S.) boarding pass – if you still have it – can help facilitate your reentry next time you come back to the United States.

and:

If you are a VWP visitor and you left the U.S. by an air or sea carrier, you don’t need to worry.

and:

We strongly urge you to keep a copy of what you send to DHS-CBP and carry it with you the next time you come to the United States in case the CBP Officer has any questions about your eligibility to enter. Carrying those materials with you will also allow your record to be corrected at the time of entry if, for some reason, the London, Kentucky office has not yet done so.

8 – Why my shopping cart item doesn’t have a label?

I’m working on D8 site with Drupal commerce.
I have to create a dynamic product variation and add to cart for the user checkout.

The problem I have, is when you landed on the cart page, the line item doesn’t have a label (title) it replaced with the price of the item. Please refer to the attached image.

Here’s my code:

   //create variation
            $variation = ProductVariation::create((
                'type' => 'fk_payment',
                'sku' => 'FK'.$faid,
                'status' => TRUE,
                'price' => new Price($trans->getTotal(), $trans->getCurrency()),
                'title' => "Example item label title",
              ));

            $variation->save();

            //Load the product
            $product_id = 4;
            $product = Product::load($product_id);
            $product->addVariation($variation);
            $product->save();

            //load store
            $storeId = $product->get('stores')->getValue()(0)('target_id');
            $store = Drupal::entityTypeManager()
            ->getStorage('commerce_store')
            ->load($storeId);
            
            //prepare cart
            $cart = Drupal::service('commerce_cart.cart_provider');
            $cart = $cart->getCart('default', $store);
            
            if (!$cart) {
                $cart = Drupal::service('commerce_cart.cart_provider');
                $cart = $cart->createCart('default', $store);
            }

            // Process to place order programatically.
            $cart_manager = Drupal::service('commerce_cart.cart_manager');

            //empty the cart
            if (!empty($cart)) {
                $cart_manager->emptyCart($cart);
            }

            $cart_manager->addEntity($cart, $variation);

enter image description here

linux boot error – black screen with blinking cursor – read cache enabled write cache enabled doesn’t support dpo or fua

Im new to linux. I have an old pc that used to run windows 7 ultimate. one day, while booting it froze at the loading logo. Tried many methods but didnt solve the boot problem. So i thought this would be a nice time to try out linux. I created a linux lite 5.2 64bit booable drive. I open boot menu and chose usd drive and a menu opened where i can choose to live boot, live boot safe mode, install, mem test and stuffs like that. when i live boot i got black screen with cursor. same happened when i chose to directly install it. so i chose safe mode and it booted but i cant connect to internet, the icons were large and resolution was reduced. somehow managed to install linuxlite 5.2 by formating the harddrive( it was given as an option in installation process). when i removed the usb and booted from hard dive i got the black screen with cursor blinking. SO i googled i came across a most common and frequent solution. that is to press “e” and type “nomodest” and erase ” quick splash” to see whats going on under the hood i guess. not sure what it is. when i did that, the boot process halted with this line ” read cache enabled, write cache enabled, doesn’t support dpo or fua”. i tried the nomodeset on live boot and it stopped booting at the same line. i tried different distros (ubuntu 20.04,10.04, lubuntu 16,18,20.04, linuxmint, linux lite 4.2, peppermint, lxle, fedora). I can’t even live boot in any other distros ( remember i was able to boot linux lite live in usb only in safe mode).

Hardware specs:

intel pentium dual core e5700 3ghz,

ASrock g41m-vs3

2gb ram

500gb hdd seagate

in short its a 11 year old potato pc.

whatever i do, i end with this one line and i cant find any solution.

read cache enabled, write cache enabled, doesnt support DPO or FUA.

grub menu i guess not sure

the cmd line i got when i preesed “e”

the error i got

tor – Proxychains doesn’t work with me

I am using Parrot OS,I have problem with proxychains
then I change my region and timezon to France because I was having problems with language and timezon, I followed this tutorial

`Gtk-WARNING **: Locale not supported by C library. ` when starting apps from the commandline

my step
install tor , install proxychains
that is what I have

abdou@parrot)─(~)
└──╼ $locate proxychains
/etc/alternatives/proxychains
/etc/alternatives/proxychains.1.gz
/etc/proxychains.conf
/home/abdou/.local/share/RecentDocuments/proxychains.conf.desktop
/home/abdou/proxychains.conf
/usr/bin/proxychains
/usr/bin/proxychains3
/usr/lib/proxychains3
/usr/lib/proxychains3/proxyresolv
/usr/lib/x86_64-linux-gnu/libproxychains.so.3
/usr/lib/x86_64-linux-gnu/libproxychains.so.3.0.0
/usr/share/applications/parrot-proxychains.desktop
/usr/share/doc/libproxychains3
/usr/share/doc/libproxychains3/changelog.Debian.gz
/usr/share/doc/libproxychains3/changelog.gz
/usr/share/doc/libproxychains3/copyright
/usr/share/doc/proxychains
/usr/share/doc/proxychains/changelog.Debian.gz
/usr/share/doc/proxychains/changelog.gz
/usr/share/doc/proxychains/copyright
/usr/share/icons/hicolor/16x16/apps/parrot-proxychains.png
/usr/share/icons/hicolor/24x24/apps/parrot-proxychains.png
/usr/share/icons/hicolor/256x256/apps/parrot-proxychains.png
/usr/share/icons/hicolor/32x32/apps/parrot-proxychains.png
/usr/share/icons/hicolor/48x48/apps/parrot-proxychains.png
/usr/share/man/man1/proxychains.1.gz
/usr/share/man/man1/proxychains3.1.gz
/usr/share/parrot-menu/applications/parrot-proxychains.desktop
/var/lib/dpkg/alternatives/proxychains
/var/lib/dpkg/info/libproxychains3:amd64.list
/var/lib/dpkg/info/libproxychains3:amd64.md5sums
/var/lib/dpkg/info/libproxychains3:amd64.shlibs
/var/lib/dpkg/info/libproxychains3:amd64.symbols
/var/lib/dpkg/info/libproxychains3:amd64.triggers
/var/lib/dpkg/info/proxychains.conffiles
/var/lib/dpkg/info/proxychains.list
/var/lib/dpkg/info/proxychains.md5sums
/var/lib/dpkg/info/proxychains.postinst
/var/lib/dpkg/info/proxychains.prerm

and proxychains.conf

# proxychains.conf  VER 3.1
#
#        HTTP, SOCKS4, SOCKS5 tunneling proxifier with DNS.
#   

# The option below identifies how the ProxyList is treated.
# only one option should be uncommented at time,
# otherwise the last appearing option will be accepted
#
dynamic_chain
#
# Dynamic - Each connection will be done via chained proxies
# all proxies chained in the order as they appear in the list
# at least one proxy must be online to play in chain
# (dead proxies are skipped)
# otherwise EINTR is returned to the app
#
#strict_chain
#
# Strict - Each connection will be done via chained proxies
# all proxies chained in the order as they appear in the list
# all proxies must be online to play in chain
# otherwise EINTR is returned to the app
#
#random_chain
#
# Random - Each connection will be done via random proxy
# (or proxy chain, see  chain_len) from the list.
# this option is good to test your IDS :)

# Make sense only if random_chain
#chain_len = 2

# Quiet mode (no output from library)
# quiet_mode

# Proxy DNS requests - no leak for DNS data
proxy_dns 

# Some timeouts in milliseconds
tcp_read_time_out 15000
tcp_connect_time_out 8000

# ProxyList format
#       type  host  port (user pass)
#       (values separated by 'tab' or 'blank')
#
#
#        Examples:
#
#               socks5  192.168.67.78   1080    lamer   secret
#       http    192.168.89.3    8080    justu   hidden
#       socks4  192.168.1.49    1080
#           http    192.168.39.93   8080    
#       
#
#       proxy types: http, socks4, socks5
#        ( auth types supported: "basic"-http  "user/pass"-socks )
#
(ProxyList)
# add proxy here ...
# meanwile
# defaults set to "tor"
socks4  127.0.0.1 9050
socks5  127.0.0.1 9050

and

    abdou@parrot)─(~)

$sudo service tor start

┌─(abdou@parrot)─(~)
└──╼ $proxychains firefox google.com
ProxyChains-3.1 (http://proxychains.sf.net)

┌─(abdou@parrot)─(~)

Why doesn’t ISO27001 mandate an acceptable use policy?

I think your issue can be summed up with a misunderstanding of the term “policy”. Many people use the term “policy” to mean many things:

  • strategy
  • guidance
  • direction
  • procedures
  • mandates
  • technical specifications

But these are all different types of documents. ISO 27000 defines “policy” specifically:

policy
intentions and direction of an organization (3.50), as formally expressed by its top management (3.75)

For A.8.1.3, they are not looking for a “policy” (i.e. intentions and directions). They are looking for “rules” (i.e. “do this”).

So, while people generally call the document an “Acceptable Use Policy” (AUP), it’s not a policy as defined by ISO 27000. It’s a set of rules users are meant to follow without deviation.

And, as you can see in the list you posted, it’s there.