How do JavaScript (and mobile) APIs keep user data clean?

Let’s say we’re running Google Analytics, and we’re tracking user specific data (or displaying contents based on that data, such as most recently viewed pages) — we add a pixel, and then we pass the user data to the Analytics platform. What’s to prevent a malicious user from passing a bunch of garbage data based on random user ids?

Same thing with mobile; let’s say we integrate a customer service SDK such as Zendesk. There’s usually either a key or a cert that we have to include in our apps. What’s to stop a malicious user from decompiling our app and then using the provided cert in the app, read all user tickets from whatever user id he passes?

And what are things we can do, both as app/web developers and SDK developers to block these types of attacks?

Clean Architecture: Dependency Rule and Libraries/Frameworks

In Clean Architecture by Robert C. Martin the dependency rule points strictly from the outermost layer/ring to the innermost.

As an example a Dependency Injection Framework should lie on the outermost layer (frameworks) to allow for it to be replaced.

However, a DI framework which relies on attributes would clearly break this, as any class which would require those attributes would have a dependency on the framework. Therefore such a library could not be used following the dependency rule strictly.

I am running into the same problem with utility libraries, e.g. a Math Library or some Rx library providing IObservables/Subjects.

The math library could be wrapped by an adapter to keep it replacable – which makes sense, but a Entity framework providing the framework for both entities (inner most layer) as well as systems (business rules) and maybe even UI (presenters) simply do not go well with this design.

However, even for the math library the cost of adding the interfaces for Dependency Inversion+Adapter sounds pretty insane.

Am I missing something or is this more or less a rule which commonly break when trying to implement Clean Architecture.

Split Windows search index per volume and selectively re-use it alter clean OS install

Windows 7+ (probably, Vista too) can create an entire index for the chosen directories and store it in one place (C:\ProgramData\Microsoft by default). Assume I have a system drive (C:\, programs and Windows itself), internal data drive (D:\, large collection of text files, office documents and PDFs) and an external storage (E:\, large media files and backups) and I added all the files stored on them to the index, which took for the Windows indexing 3 or 4 days to finish working 24/7 (fulltext indexing enabled).

When I decided to do a clean Windows (re)install, I moved index files from the drive C:\ to D:\ thinking that I can change location in the indexing options of the freshly installed Windows 10 so that the former index will be picked up and it only is going to check the altered volume (C:\, in this case). However, it had the reverse effect: Windows 10 indexing never finished adjusting after clean install, fulltext search didn’t work at all and I had to recreate the index again (took the laptop another 3 days working 24/7).

At this point I’m wondering whether it is possible to store indices discretely on each volume only with the search data for the files stored there. If not, what’s the best strategy for preserving previously created index across multiple drives, including the system one, for the clean install of the Windows so that it’ll be able to pick it up and use again without fully recreating?

Windows Service 24/7 consistent with clean architecture

I have to write windows service running 24/7. Service must process documents from various sources. I wrote some code but, I don’t know how to apportion it on assemblies and folders consistent with clean architecture. It is windows servide so I don’t have presentation layer. Can I count on some advices? This is simpler version of my code:

Configuration

public interface IConfiguration  {       int ThreadCount { get; set; }        Dictionary<string, string> ConnectionStrings { get; set; }  }   public class Configuration : IConfiguration  {       public int ThreadCount { get; set; }        public Dictionary<string, string> ConnectionStrings { get; set; }  }   public interface IDocumentProviderConfiguration  {       string Name { get; set; }        string Type { get; set; }        string StoredProcedure { get; set; }        string ConnectionString { get; set; }  }   public class DocumentProviderConfiguration : IDocumentProviderConfiguration  {       public string Name { get; set; }        public string Type { get; set; }        public string StoredProcedure { get; set; }        public string ConnectionString { get; set; } } 

Root class

public interface IService { }  public class Service : IService {     private readonly CancellationTokenSource _cancellationTokenSource;     private readonly CancellationToken _cancellationToken;     private readonly List<Task> _tasks;      private readonly IConfiguration _configuration;     private readonly IFeedingProvider _feedingProvider;      public Service(IConfiguration configuration, IFeedingProvider feedingProvider)     {         this._configuration = configuration;         this._feedingProvider = feedingProvider;          _cancellationTokenSource = new CancellationTokenSource();          _cancellationToken = _cancellationTokenSource.Token;          _tasks = new List<Task>();     }      public void StartProcessing()     {         _feedingProvider.Start();          for (var i = 0; i < _configuration.ThreadCount; i++)         {             _tasks.Add(Task.Run(()=>RunProcessor(), _cancellationToken));         }     }      public void StopProcessing()     {         _feedingProvider.Stop();          _cancellationTokenSource.Cancel();          Task.Factory.ContinueWhenAll(_tasks.ToArray(), result =>{ }).Wait();     }      public void RunProcessor()     {         System.Diagnostics.Debug.Print("started");          var processor = new TestProcessor();         try         {             while (!_cancellationTokenSource.IsCancellationRequested)             {                 var sleepTime = 1000;                 using (var item = _feedingProvider.Dequeue())                 {                     if (item != null)                     {                         var result = processor.Process(item);                          //log                          item.Commit();                          sleepTime = 0;                     }  Task.Delay(sleepTime, _cancellationToken).Wait(_cancellationToken);                 }             }         }         catch (Exception exception)         {             if (!_cancellationToken.IsCancellationRequested)             {                //log             }         }     } } 

Feeding part

   public interface IItem: IDisposable     {         Guid Id { get; set; }          void Commit();     }      public interface IDocumentProvider     {         IEnumerable<IItem> GetItems();     }      public interface IFeedingProvider     {         void Start();          void Stop();          IItem Dequeue();     }      public class FeedingProvider: IFeedingProvider     {         private readonly ConcurrentQueue<IItem> queue;          private List<IDocumentProvider> documentProviders;          private readonly Timer feedingTimer;          public FeedingProvider()         {             queue = new ConcurrentQueue<IItem>();              feedingTimer = new Timer(2000);         }          public void Start()         {             feedingTimer.Start();         }          public void Stop()         {             throw new NotImplementedException();         }          public IItem Dequeue()         {             queue.TryDequeue(out var item);              return item;         }          public void Load()         {             foreach (var documentProvider in documentProviders)             {                 foreach (var item in documentProvider.GetItems())                 {                     queue.Enqueue(item);                 }             }         }     } 

Process Part

  public abstract class Processor     {         public abstract ProcessingResult Process(IItem item);     }      public class TestProcessor: Processor     {         private readonly ICustomerProvider _customerProvider;         private readonly IDocumentRepository _documentRepository;          public TestProcessor(ICustomerProvider customerProvider, IDocumentRepository documentRepository)         {             _customerProvider = customerProvider;             _documentRepository = documentRepository;         }          public override ProcessingResult Process(IItem item)         {             //Processsing Item             //Use _customerProvider             //Use _documentRepository             return new ProcessingResult             {                 IsSuccess = true             };         }     }      public class ProcessingResult     {         public bool IsSuccess { get; set; }     } 

DocumentProvider part

   public class TestDocumentProvider : IDocumentProvider     {         private readonly IDocumentProviderConfiguration _documentProviderConfiguration;          public TestDocumentProvider(IDocumentProviderConfiguration documentProviderConfiguration)         {             _documentProviderConfiguration = documentProviderConfiguration;         }          public IEnumerable<IItem> GetItems()         {             foreach (DataRow row in GetDataTable().Rows)             {                 yield return new TestDocument(row);             }         }          public DataTable GetDataTable()         {             throw new NotImplementedException();         }     }      public class TestDocument: IItem     {         public Guid Id { get; set; }          private DataRow dataRow;          public TestDocument(DataRow dataRow)         {             this.dataRow = dataRow;         }          public void Commit()         {             throw new NotImplementedException();         }          public void Dispose()         {             throw new NotImplementedException();         }     } 

Additional parts

 public interface IDbProvider     {         void ExSPNonQuery(string sqlCommandName, List<SqlParameter> sqlParams = null);          DataTable ExSPDataTable(string sqlCommandName, List<SqlParameter> sqlParams = null);     }      public class DbProvider: IDbProvider     {         private  string connectionString { get; set; }          public DbProvider(string connectionString)         {             this.connectionString = connectionString;         }          public void ExSPNonQuery(string sqlCommandName, List<SqlParameter> sqlParams = null)         {             throw new NotImplementedException();         }          public DataTable ExSPDataTable(string sqlCommandName, List<SqlParameter> sqlParams = null)         {             throw new NotImplementedException();         }     }   public interface ICustomerRepository     {         IEnumerable<Customer> GetCustomers();     }      public class CustomerRepository: ICustomerRepository     {         private readonly IDbProvider dbProvider;          public CustomerRepository(IDbProvider dbProvider)         {             this.dbProvider = dbProvider;         }          public IEnumerable<Customer> GetCustomers()         {             var customers = dbProvider.ExSPDataTable("dbo.GetCustomers");              return customers.AsEnumerable().Select(c => new Customer             {                 Id = c.Field<int>("Id"),                 Name = c.Field<string>("Name")             });         }     }      public class Customer     {         public int Id { get; set; }         public string Name { get; set; }     }  public interface IDocumentRepository     {         void AddSomethingToDocument();          void DeleteSomethingFromDocument();     }      public class DocumentRepository : IDocumentRepository     {         private readonly IDbProvider dbProvider;          public DocumentRepository(IDbProvider dbProvider)         {             this.dbProvider = dbProvider;         }          public void AddSomethingToDocument()         {             throw new NotImplementedException();         }          public void DeleteSomethingFromDocument()         {             throw new NotImplementedException();         }       } 

Why is it so difficult to do CLEAN uninstalls?

So I installed netbeans for my Java class through the apt install method. Which isnt great because its 8.1 not 8.2 and there’s some issue where I cant open pdf files from that netbeans version.

So I removed it using apt and downloaded the actual 8.2 file off the netbeans website. Installed it using ./

Now it doesnt have all the extra options under the tools section.

IDK, why is this so difficult?

Clean Win10 install on MSI GS65 Stealth Thin RF8

The laptop came with a M.2 SATA SSD (SanDisk). Initially it booted from Windows installer without issue.

Even after I reimaged the drive to a whole disk encrypted ubuntu luks partition and grub boot loader. Even after that, I could boot from the Windows media without issue.

I then bought an additional NVMe M.2 storage device (Patriot Scorch) as an expansion drive, and installed it the second available PCIe slot (labeled SSD #2).

I intended to install Win10 to this device. However, whenever I boot from USB installation media (both 1809_english_x64 and 1803_english_x64) generated with dd, I always recieve a missing driver error and the installation halts almost immediately.

What’s really frustrating about it, is the Windows installer doesn’t tell you what driver is missing! So I presumed it was the NVMe, or a mixture of the SATA and NVMe on the same board. I thought this, because it was clearly the intervening event.

So I pulled out the SATA first, and tried booting from both versions of the Win10 install media. Same driver problem. I then pulled the NVMe and replaced the SATA. Again, the same missing driver error.

So now, it would appear that it’s not the storage devices at all?!

Ubuntu install went flawlessly, and the OS recognized both drives, with the SATA running a achi driver, and the NVMe running a generic nvme driver. No issues formatting, mounting, creating / deleting files in linux. It appears to be an issue with the installation media. Still haven’t tried flashing CMOS, though.

Is there any way to tell what driver is missing from the Win10 media? That or some verbose logging on the Win10 installer? It’s a pain in the butt to keep guessing and having installs fail over and over again.

Thanks for any help, M

How do I verify my second-hand phone is ‘clean’

I have just bought a second-hand Android phone (Samsung) and would like to check that there’s nothing nasty on there before I start using it in earnest. It’s my first smartphone! I have some experience with Linux Mint, but not a lot.

I’ve compiled a list of the apps installed (not system apps) and I would like to understand the origin of each and, on a superficial level at least, the purpose of each. I’m finding it hard to find some of this info, e.g. what is ‘OM Customize’. Is there a good encyclopedia of Android apps out there that I’ve missed so far? I could post the list here if anyone can help?

The phone was very cheap, and I’m wondering whether there’s some security tool I should use to check it, and potentially whether I should look at rooting it. My main usage at the moment is actually just going to be as a GPS tool and note-taker, so not particularly interested in the ‘normal’ bells and whistles applications.

Detonation your business I can provide your targeted clean email listing for marketing for $10

Happy New Year -2019 I am right here to be hired through the medium of an email Marketer. I’ve extra than 01 Years enjoy approximately virtual advertising.E-mail Its is my passion, in case you order me: I’m master of E- mail listing collection. E-mail advertising most critical part of E- mail advertising for online enterprise. It is the most famous advertising way in the whole international. To sell a commercial enterprise email advertising and marketing is the pleasant medium these days. I assume you want an E-mail list. I can provide niche Base energetic electronic mail listing which is one hundred percent Active, Fresh, Valid fresh and Business E-mail were amassed from LINKEDIN, Google and other trustworthy professional Search Engine. My services comprise: Any corporate character E-mail lists. Any commercial enterprise E-mail lists. Any area of interest based E-mail listing. B2B mail listing. United states Base electronic mail list. Non-public electronic mail listing. Organisation email listing. Lead generation E-mail list. Any targeted E-mail lists. Any region based totally E-mail lists. Any bulk e mail List 100% valid electronic mail list. Associate E-mail and make contact with Information No fake E-mail Active, sparkling, legitimate and Targeted business E-mail All E-mail are u.s.a united kingdom,, Germany, Japan and others treasured international locations I am offering 100% delighted Satisfactory. In any case you aren’t satisfied, then I assured you to refund your money. For any types of e mail listing, you want to touch me before placing the order. thanks for looking my provider and have a pleasing upcoming Year 2019.

by: SeoExpertbd143
Created: —
Category: Email & Newsletters
Viewed: 393


How can I write clean and simple code many if and else

I just wrote this code. But I want to change this code simple and clean.

Do you have any feedback?

try {         if (!videoFile.exists()) {             videoFile.createNewFile();         } else {             videoFile.delete();             videoFile.createNewFile();         }         if (!cnFile.exists()) {             cnFile.createNewFile();         } else {             cnFile.delete();             cnFile.createNewFile();         }         if (!enFile.exists()) {             enFile.createNewFile();         } else {             enFile.delete();             enFile.createNewFile();         }     } catch (IOException e) {         e.printStackTrace();     } 

Clean code (C#)

I Want to write clean and easy to maintainable code. What can I improve on below code?

Below is example of my masterdata service, which receive master data as json input, after some validation I need to create/update/delete master data into Cosmos DB.

public class MasterService : IMasterService {     private readonly IMasterDao masterDataService;     private readonly ILog log;      public MasterService(IMasterDao masterDataService, ILog log)     {         this.log = log;         this.masterDataService = masterDataService;     }      public async Task<bool> UpdateMasterData(string message, string windowsZonesFilePath)     {         this.ValidateArgument<ArgumentException>(() => string.IsNullOrWhiteSpace(message), "Invalid MasterData Message");         Dictionary<string, object> json = JsonConvert.DeserializeObject<Dictionary<string, object>>(message);         this.ValidateArgument<ArgumentException>(() => !json.ContainsKey("OperationType"), "OperationType doesn't exist");         this.ValidateArgument<ArgumentException>(() => !json.ContainsKey("AssetType"), "AssetType doesn't exist");         this.ValidateArgument<ArgumentException>(() => !json.ContainsKey("AssetId"), "AssetId doesn't exist");          string operationType = json["OperationType"].ToString().ToUpper();         string assetType = json["AssetType"].ToString();         string assetId = json["AssetId"].ToString();         //TimeZone only mandatory for Plant asset         if (assetType.Equals("Plant", StringComparison.InvariantCultureIgnoreCase) && json.ContainsKey("PlantAffiliationType")             && json["PlantAffiliationType"].ToString().Equals("owner", StringComparison.InvariantCultureIgnoreCase))         {             this.ValidateArgument<ArgumentException>(() => !json.ContainsKey("TimeZone"), "TimeZone doesn't exist");             string timeZone = json["TimeZone"].ToString();             string newTimeZone = GetTimeZone(windowsZonesFilePath, timeZone);             json["TimeZone"] = newTimeZone;         }          log.Info($  "DATA received for AssetType : {assetType} with AssetId : {assetId} and operationType : {operationType}");          if (!json.Keys.Contains("ApplicationName"))             json.Add("ApplicationName", AMSConstraints.ApplicationName);          JObject newMessage = JObject.Parse(JsonConvert.SerializeObject(json));          if (operationType.Equals(OperationType.New.ToString(), StringComparison.InvariantCultureIgnoreCase))         {             log.Info($  "Adding in database");             await this.masterDataService.CreateAsync(newMessage);             return true;         }         else if (operationType.Equals(OperationType.Update.ToString(), StringComparison.InvariantCultureIgnoreCase))         {             log.Info($  "Replacing in database");             return await this.masterDataService.UpdateDocumentByAsset(assetId, assetType, newMessage);         }         else if (operationType.Equals(OperationType.Delete.ToString(), StringComparison.InvariantCultureIgnoreCase))         {             log.Info($  "Deleting Document");             return await this.masterDataService.DeleteAsset(assetId, assetType);         }         return false;     }      private string GetTimeZone(string filePath, string timeZone)     {         XDocument xdoc = XDocument.Load(filePath);         return xdoc.Descendants("mapZone")                     .Where(x => x.Attribute("other").Value.Equals(timeZone, StringComparison.InvariantCultureIgnoreCase))                     .Select(x => (string)x.Attribute("type"))                     .FirstOrDefault();     }      private void ValidateArgument<exType>(Func<bool> validation, string errorMessage) where exType : Exception     {         if (validation())         {             throw Activator.CreateInstance(typeof(exType), errorMessage) as exType;         }     } }