Avoid specific messages like TTY=unknown from logging in /var/log/messages

I am receiving the messages in /var/log/messages and this is populating my /var partition with more space:

“Jun 6 04:02:58 sdp-A sudo: apache : TTY=unknown ; PWD=/var/Tapps/appworks/public ; USER=root ; COMMAND=/bin/rpm -q Tuser”

I want to stop this message from piling up my /var/log/messages , I know logrotate but I am looking for a solution other than logrotate to stop this.

How to avoid circular references in JavaScript?

I have two classes. A Bot class and a Client class.

Heres a relevant section of the Bot class.

class Bot {     constructor(client) {         this.client = client;         this.client.on(ChatEvent.NEW_MESSAGE, this.processMessage.bind(this));         this.client.on(ChatEvent.EDIT, this.processMessage.bind(this));     }      async processMessage(msg) {}     saveData(name, data){} } 

As you can see the Bot constructor accepts a Client instance.

Here’s a relevant section of the Client class.

class Client {    async getSites() {         let sites = this.bot.loadData('sites', sites);         if(rep){           return sites;         }         resp = await request({             [...]         });         sites = JSON.parse(resp);         this.bot.saveData('sites', sites);         return sites;      } } 

The Client class needs to access the Bot instance in the line this.bot.loadData and this.bot.saveData.

How can I do this without a circular reference?

Ideally I would want to be able to do:

const bot = new Bot(new Client([...])); 

The following way might work, but it uses a circular references:

bot = new Bot(); bot.client = new Client(bot); 

How to avoid saving a value of property of form object when saving changes to db

In a crud asp.net core 2.2 web app, I need to avoid saving a property of form object to db. How do I do that?

I’ve tried using [Editable(false)] data annotation on the ListBin property to prevent saving property value to db.

[Table("supply_lists")] public partial class SupplyLists {     [Column("id")]     public int Id { get; set; }     [Column("category_id")]     public int CategoryId { get; set; }     [Required]     [Column("coursecode")]     [StringLength(200)]     public string Coursecode { get; set; }     [Required]     [Column("title")]     [StringLength(200)]     public string Title { get; set; }     [Required]     [Column("filename")]     [StringLength(200)]     public string Filename { get; set; }     [Column("isactive")]     public bool Isactive { get; set; }     [Column("date", TypeName = "smalldatetime")]     public DateTime Date { get; set; }      [Column("list_bin")]     public byte[] ListBin { get; set; }      [ForeignKey("CategoryId")]     [InverseProperty("SupplyLists")]     public virtual SupplyListCategory Category { get; set; } }   [ModelMetadataType(typeof(MetaDataTypeModel))] public partial class SupplyLists {  } public class MetaDataTypeModel {     [Editable(false)]     public byte[] ListBin { get; set; }      [Display(Name = "Is Active")]     public bool Isactive { get; set; }      [Display(Name ="Course Code")]     public string Coursecode { get; set; }      [Display(Name = "Category")]     public int CategoryId { get; set; }      [DataType(DataType.Date)]     public DateTime Date { get; set; } }  public class EditModel : PageModel {     private readonly SupplyListCore22.Models.SupplyListsContext _context;     private readonly IHostingEnvironment _env;      public EditModel(SupplyListCore22.Models.SupplyListsContext context, IHostingEnvironment env)     {         _context = context;         _env = env;     }      [BindProperty]     public SupplyLists SupplyLists { get; set; }     [BindProperty]     public FileUpload FileUpload { get; set; }      public async Task<IActionResult> OnGetAsync(int? id)     {         if (id == null)         {             return NotFound();         }          SupplyLists = await _context.SupplyLists             .Include(s => s.Category).FirstOrDefaultAsync(m => m.Id == id);          if (SupplyLists == null)         {             return NotFound();         }        ViewData["CategoryId"] = new SelectList(_context.SupplyListCategory, "Id", "Category");         return Page();     }      public async Task<IActionResult> OnPostAsync()     {         //if (!ModelState.IsValid)         //{         //    return Page();         //}          _context.Attach(SupplyLists).State = EntityState.Modified;         await _context.SaveChangesAsync();          if (FileUpload.UploadSupplyList != null)         {             var fileUploadData = await utilities.utilities.ProcessFormFile(FileUpload.UploadSupplyList, ModelState);             if (ModelState.ErrorCount > 0)             {                 ViewData["CategoryId"] = new SelectList(_context.SupplyListCategory, "Id", "Category");                 return Page();             }             var sl = _context.SupplyLists.Find(SupplyLists.Id);             sl.ListBin = fileUploadData;              await _context.SaveChangesAsync();          }          return RedirectToPage("./Index");     } 

It set the ListBin to null in db which is not what I wanted when saving changes (I wanted to preserve the old value of ListBin in db).

Is it a good security practice to force employees hide their employer to avoid being targeted?

A young tech company which operates on sensitive data has employees that fall victim to phishing/porting scams despite its best efforts to instill security fobs, vpn, password managers, non-sms 2FA, limited email access and so on.

Is it a good practice to force employees to hide their employment status from the public to avoid being targeted for hacking (e.g. remove the employer from LinkedIn)?

Design choice to avoid lock contention

I have a network application F. It receives requests from one (or many) client network function. F can handle multi-client requests using an epoll loop. F maintains a state machine for each client(user). F also maintains some context for each user or client. Whenever a message is received from a client network function (by one user), F processes the message and if required fetch context specific to this user and updates the context.

Currently, the contexts of different users are maintained in a C++ STL map.

map<clientId,context> userMap; 

where clientId is an integer and context is a struct containing user-specific data. Whenever I need to access the userMap I would take a lock first, access the data, and then unlock.

For example, if a client sends a request message X. The server F, epoll_wait() will get the event (i.e. the incoming message). Then this messages is read from the socket and processed further. In the server handleX() method will be invoked (if user state and context is consistent and allows for handleX to be executed for this user). Each of these handleX function needs the current user context for some computation. it locks the userMap, gets or set the data, and then unlocks it.

In the single threaded version of F, a single thread only waits for events and processes those events one by one.

I tried to use a thread pool to check the multicore scalability of F. In this case, a single thread reads the messages from the socket and puts those messages in a queue. A pool of threads are waiting on the queue and picks any messages that pushed on the queue. But the throughput is not better than single-threaded code version of F.

I think locking is inherently serializing the F‘s code. I would like to know is there any other model of user context store and retrieve to minimize lock contention?

Thanks!

[TIPS] 13 SEO Bad Practices you want to avoid !!

You'll find a small check list of things to not do when you are building a website and expecting to get some traffic. It would either cause a penalty or a loss in SEO juice.

1) No text in Image : A common mistake to avoid ! Content is king in search engine optimization. With CSS3 and html5 you can have some great font design which can be indexed. But if you use it in pictures / images it is a missed opportunity ! Especially in your logo / slogans

2) No Ads : If you can afford to…

[TIPS] 13 SEO Bad Practices you want to avoid !!

How can the PCs avoid this consequence in the season 8 epic, Stardock Under Siege?

Stardock Under Siege (DDEP08-02) concludes with all of the tables in the Epic boarding skiffs and facing off against a massive mothership. The PCs are tasked with destroying the mothership before time runs out. At the end of each round, runners from each table report their table’s damage total. If the mothership reaches zero HP in time, it is successfully destroyed.

The mothership has an AC and a damage threshold, allowing it to be attacked with the normal rules for attacking objects. Ranged attacks and spells are viable options that allow the PCs to keep their distance. The PCs can also choose to board the mothership and attack it in melee. Any PC on the mothership when it is destroyed is subject to an effect, but each PC may first take a reaction. The effect does not call for a saving throw, attack roll, or ability check. The full (spoilery) quote from the adventure is as follows (Stardock Under Siege, p. 34):

Are there AL-legal features or magic items that allow movement, teleportation, or appropriate defenses as a reaction, without a specific trigger? Is there something that I missed from the adventure (besides simply not boarding the mothership) that would allow the PCs to avoid the effect? Has there been an official confirmation that the effect should work as described?

Bonus points for solutions that work for a variety of PCs in Tiers 1-3, the tier range for the Epic. Don’t forget that the party also needs to damage the mothership, so “just keep Readying movement” won’t work, unless the party can also deal damage.

How to avoid code duplication caused by javascript dict access?

I have two functions that group a list of dicts according to the value of a certain key. Here’s how my array looks:

const sections = [   {     file_id: '1',     heading_level: 4,     readme_file_name: 'Quick.Quick.md',     section_codes: [       1,       3,     ],     section_id: '1',     title: 'Nimble',   },   {     file_id: '1',     heading_level: 2,     readme_file_name: 'Quick.Quick.md',     section_codes: [       3,       4,     ],     section_id: '2',     title: 'Swift Version',   },   // ... ]; 

Some times I need to group the sections by it’s heading_level key value, and other times I need to group by the first value on section_codes array.

I’ve created a single function for each grouping, but the code is exactly the same, except for the line where I access the desired key. So I’ve tried removing duplication, and here’s where I’ve gotten so far:

// Helper func function getValueForKey(key, section) {   const originalValue = section[key];    if (Array.isArray(originalValue)) {     return originalValue[0];   }    return originalValue; }  export function groupSectionsByKey(key, sections) {   const groupedSections = {};    sections.forEach((section) => {     const groupKey = getValueForKey(key, section);     const codeArray = groupedSections[groupKey];      if (codeArray) {       codeArray.push(section);     } else {       groupedSections[groupKey] = [section];     }   });    return groupedSections; } 

This getValueForKey function seems a bit off for me, but I’m not sure if there is a better way to do this. Does anyone have some feedback?

Thanks.

How to avoid dependency on time? [on hold]

We are developing a payroll system and everything depends heavily on the time. Here are some examples which affect the salary:

  • The time that an employee signs the agreement.
  • The time he enters the office and the time he leaves.
  • The employee’s shift plan history.(His older salaries should be calculated based on his older shift plans)
  • His vacations’ request time(and whether it’s been in his working hours).
  • His mission time(and whether it’s been in his working hours).
  • The time we pay him, and so on!

If the date of the hardware changes accidentally, the system may damage seriously because of invalid data entry. How to remove the depemdency on the time?