投稿時間:2023-05-01 02:11:24 RSSフィード2023-05-01 02:00 分まとめ(15件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
海外TECH MakeUseOf What Is Denuvo and Why Does Everyone Hate It? https://www.makeuseof.com/what-is-denuvo/ cheat 2023-04-30 16:45:17
海外TECH MakeUseOf How to Back Up Logic Pro (And Why You Should) https://www.makeuseof.com/how-to-back-up-logic-pro/ logic 2023-04-30 16:45:16
海外TECH MakeUseOf Chevrolet Corvette E-Ray: Exploring This Exciting Hybrid Sports Car https://www.makeuseof.com/chevrolet-corvette-e-ray-hybrid-overview/ Chevrolet Corvette E Ray Exploring This Exciting Hybrid Sports CarEven though the Corvette E Ray breaks with tradition in several ways Chevrolet says this hybrid enhances the company s trademark driving excitement 2023-04-30 16:31:16
海外TECH MakeUseOf How to Create a Self-Extracting SFX Archive in Windows 11 https://www.makeuseof.com/create-self-extracting-sfx-archive-windows-11/ archive 2023-04-30 16:15:16
海外TECH MakeUseOf 3 Scams to Watch Out for in 2023 https://www.makeuseof.com/scams-to-watch-out-for-right-now/ scams 2023-04-30 16:01:16
海外TECH DEV Community How to develop an online code compiler using Java and Docker. https://dev.to/zakariamaaraki/how-to-develop-an-online-code-compiler-using-java-and-docker-2oe8 How to develop an online code compiler using Java and Docker Have you ever wondered how platforms such as Codeforces and LeetCode operate How do they compile and run multiple user s code against test cases How do they determine the efficiency of algorithms In this article we will delve into the process of building a highly effective problem solving platform The source code for this amazing article can be found in our secret underground lair i mean my Github repository Sourcecode Specification FunctionalOur platform should be Able support multiple programming languages Able of executing user code against multiple test casesAble to return a correct verdict after the execution list of verdicts Accepted Wrong Answer Time Limit Exceeded Memory Limit Exceeded Runtime Error Compilation Error Able to return a detailed error to the user if the verdict is one of these Time Limit Exceeded Compilation Error Runtime Error Memory Limit Exceeded Able to return the compilation duration Able to return the execution duration for each test case Non FunctionalOur platform should Be able to execute multiple requests concurrentlySeparate executions environments malicious user code should not be able access machine host Should not let the code running if it exceed the time limit For each request the user code should be compiled once and executed multiple times against test cases User should not be able to access host file system InterfaceExample of input testCases test input lt YOUR INPUT gt expectedOutput lt YOUR EXPECTED OUTPUT gt test input lt YOUR INPUT gt expectedOutput lt YOUR EXPECTED OUTPUT gt sourceCode lt YOUR SOURCE CODE gt language JAVA timeLimit memoryLimit Examples of outputs verdict Accepted statusCode error testCasesResult test verdict Accepted verdictStatusCode output error expectedOutput executionDuration test verdict Accepted verdictStatusCode output error expectedOutput executionDuration compilationDuration averageExecutionDuration timeLimit memoryLimit language JAVA dateTime T verdict Runtime Error statusCode error panic runtime error integer divide by zero n ngoroutine running nmain main n t app main go xb n testCasesResult test verdict Accepted verdictStatusCode output error expectedOutput executionDuration test verdict Runtime Error verdictStatusCode output error panic runtime error integer divide by zero n ngoroutine running nmain main n t app main go xb n expectedOutput executionDuration compilationDuration averageExecutionDuration timeLimit memoryLimit language GO dateTime T Implementation Separate environments of executionsTo separate environments for execution we can use containers The concept is to take the user provided source code and create a Docker image that includes information about the execution time limit memory limit source code test cases etc and run this container against multiple test cases Depending on the container s exit code we can determine the outcome of the execution Accepted Wrong Answer Time Limit Exceeded Memory Limit Exceeded Runtime Error Compilation Error Some benefits of using containers Isolation Containers provide a way to isolate applications from one another as well as from the host system This can help to prevent conflicts and improve security Portability Containers package all of the dependencies required for an application to run making it easy to move the application between different environments Consistency Because containers package all of the dependencies required for an application to run it can help to ensure that the application behaves consistently across different environments Scalability Containers can be easily scaled up or down to meet changing demand making it easy to manage resources and ensure that applications are always running at optimal performance Cost effectiveness Using containers can help to reduce the cost of running and managing applications as they are lightweight and require fewer resources than traditional virtual machines Flexibility Containers can be deployed in a variety of environments including on premises in the cloud or in a hybrid environment making them very flexible As mentioned in the image above we need two types of containers Compilation Containers and Execution Containers Each request will create one image of these type of containers then it will create one container instance of the compilation container image and multiple instances one for each test case of the execution container image Compilaton ContainersThese type of containers used to compile the sourcecode into binary these containers are very special because they share the volume with main service Example FROM openjdk jdk slimWORKDIR appENTRYPOINT bin sh c javac d EXECUTION PATH EXECUTION PATH SOURCE CODE FILE NAME amp amp rm EXECUTION PATH SOURCE CODE FILE NAME Execution ContainersThese type of containers contains all informations about the execution and this container is executed for each test case and it s isolated don t share the volume with any application or container Example FROM openjdk jre slimWORKDIR appUSER rootRUN groupadd r user g amp amp useradd u r g user s sbin nologin c Docker image user userADD RUN chmod a x entrypoint shUSER userENTRYPOINT bin sh c entrypoint TEST CASE ID sh As mentioned in the Dockerfile the container entrypoint file and has as prefix TEST CASE ID it s generated by the application for each test case using a template usr bin env bashulimit s compiler memoryLimit timeout s SIGTERM compiler timeLimit compiler executionCommand exit The template contains the time limit and the memory limit allowed for each test case Security policyFor security reasons and to prevent the user from accessing the fil system we can use Security policies For java we have security policies that are used to control access to system resources such as files and network connections for Java applications The Java security manager is responsible for enforcing these policies The security manager can be configured to grant or deny permissions to specific code based on the code s origin such as its location on the file system or its digital signature grant permission java io FilePermission tmp test txt read write permission java net SocketPermission www example com connect The above policy can be set as a command line argument when starting the JVM like this java Djava security policy mypolicy policy MyApp User requestUser input will look like this Getter NoArgsConstructor EqualsAndHashCode AllArgsConstructorpublic class Request The Source code ApiModelProperty notes The sourcecode NonNull JsonProperty sourcecode protected String sourcecode The Language ApiModelProperty notes The programming language NonNull JsonProperty language protected Language language The Time limit ApiModelProperty notes The time limit in sec NonNull JsonProperty timeLimit protected int timeLimit The Memory limit ApiModelProperty notes The memory limit NonNull JsonProperty memoryLimit protected int memoryLimit The Test cases ApiModelProperty notes The test cases NonNull JsonProperty testCases protected LinkedHashMap lt String TestCase gt testCases Note test cases should be given in order For each test case we ll have and input and an expected output Getter AllArgsConstructor EqualsAndHashCodepublic class TestCase ApiModelProperty notes The input can be null JsonProperty input private String input ApiModelProperty notes The expected output can not be null NonNull JsonProperty expectedOutput private String expectedOutput Compilation StrategyHere is a code snippet on how compilation is done for compiled languages We can use strategy pattern to chose which algorithm should be used for compiled or interpreted languages Override public CompilationResponse compile Execution execution repository name must be lowercase String compilationImageName IMAGE PREFIX NAME execution getLanguage toString toLowerCase If the app is running inside a container we should share the same volume with the compilation container final String volume compilationContainerVolume isEmpty System getProperty user dir compilationContainerVolume String sourceCodeFileName execution getSourceCodeFile getOriginalFilename String containerName COMPILATION CONTAINER NAME PREFIX execution getImageName var processOutput new AtomicReference lt ProcessOutput gt compilationTimer record gt processOutput set compile volume compilationImageName containerName execution getPath sourceCodeFileName ProcessOutput compilationOutput processOutput get int compilationDuration compilationOutput getExecutionDuration ContainerInfo containerInfo containerService inspect containerName ContainerHelper logContainerInfo containerName containerInfo Verdict verdict getVerdict compilationOutput compilationDuration ContainerHelper getExecutionDuration containerInfo null null containerInfo getStartTime containerInfo null null containerInfo getEndTime compilationDuration ContainerHelper deleteContainer containerName containerService threadPool return CompilationResponse builder verdict verdict error compilationOutput getStdErr compilationDuration compilationDuration build Execution StrategyHere is a code snippet on how an execution is done public ExecutionResponse run Execution execution boolean deleteImageAfterExecution buildContainerImage execution var testCasesResult new LinkedHashMap lt String TestCaseResult gt Verdict verdict null String err for ConvertedTestCase testCase execution getTestCases TestCaseResult testCaseResult executeTestCase execution testCase testCasesResult put testCase getTestCaseId testCaseResult verdict testCaseResult getVerdict log info Status response for the test case is testCase getTestCaseId verdict getStatusResponse Update metrics verdictsCounters get verdict getStatusResponse increment if verdict Verdict ACCEPTED Don t continue if the current test case failed log info Test case id failed abort executions testCase getTestCaseId err testCaseResult getError break Delete container image asynchronously if deleteImageAfterExecution ContainerHelper deleteImage execution getImageName containerService threadPool return ExecutionResponse builder verdict verdict testCasesResult testCasesResult error err build private TestCaseResult executeTestCase Execution execution ConvertedTestCase testCase log info Start running test case id testCase getTestCaseId String expectedOutput testCase getExpectedOutput Free memory space testCase freeMemorySpace var result new AtomicReference lt TestCaseResult gt executionTimer record gt Run the execution container result set runContainer execution testCase getTestCaseId expectedOutput TestCaseResult testCaseResult result get return testCaseResult Each programming language has it s own execution parameters and specific configuration To make this abstract we can use dependency inversion principle by creating Execution classes using abstract factory pattern Abstract FactoryThe Abstract Factory pattern is a design pattern that provides a way to create families of related or dependent objects without specifying their concrete classes It is used to create objects that belong to a single family but are not meant to be used together FunctionalInterfacepublic interface AbstractExecutionFactory Create execution param sourceCode the source code param testCases the test cases param timeLimit the time limit param memoryLimit the memory limit return the execution Execution createExecution MultipartFile sourceCode List lt ConvertedTestCase gt testCases int timeLimit int memoryLimit public abstract class ExecutionFactory private static Map lt Language ExecutionType gt registeredExecutionTypes new EnumMap lt gt Language class private static Map lt Language AbstractExecutionFactory gt registeredFactories new EnumMap lt gt Language class private ExecutionFactory Register param language the language param factory the factory public static void registerExecution Language language AbstractExecutionFactory factory registeredFactories putIfAbsent language factory Register execution type param language the language param executionType the execution type public static void registerExecutionType Language language ExecutionType executionType registeredExecutionTypes putIfAbsent language executionType Gets execution type param language the language return the execution type public static ExecutionType getExecutionType Language language return registeredExecutionTypes get language Gets registered factories return the registered factories public static Set lt Language gt getRegisteredFactories return registeredFactories keySet stream collect Collectors toSet Gets execution param sourceCode the source code param testCases the test cases param timeLimit the time limit param memoryLimit the memory limit param language the language return the execution public static Execution createExecution MultipartFile sourceCode List lt ConvertedTestCase gt testCases int timeLimit int memoryLimit Language language AbstractExecutionFactory factory registeredFactories get language if factory null throw new FactoryNotFoundException No ExecutionFactory registered for the language language return factory createExecution sourceCode testCases timeLimit memoryLimit All languages can be registered in a config class private void configureLanguages Register factories register Language JAVA sourceCode testCases timeLimit memoryLimit gt new JavaExecution sourceCode testCases timeLimit memoryLimit ExecutionFactory getExecutionType Language JAVA register Language PYTHON sourceCode testCases timeLimit memoryLimit gt new PythonExecution sourceCode testCases timeLimit memoryLimit ExecutionFactory getExecutionType Language PYTHON For more information about Execution class and how it creates an environment of execution see Execution class How to compute the compilation and the execution durationsWell we can levrage the docker inspect command to get all details about the container date of creation date of start execution status date of end execution exit status Docker InspectYou can use the docker inspect command by specifying the container or image ID or the container or image name as the argument For example to inspect a container named my container you would run the following command docker inspect my containerYou can also use the format option to display only specific fields or to format the output in a specific way docker inspect format json Config my containerFor more details see the complete sourcecode of the application Other things available in the codebaseHelm chart to deploy the service in Ks Helm chartsProvisioning of the infrastructure on Azure using ARM templateLocal execution using docker compose including communication between RabbitMq and ApacheKafka docker compose ConclusionCreating a problem solving platform can be a challenging task but the use of containers can make the process much more manageable With the many benefits of containers such as isolation portability consistency scalability and cost effectiveness it s easy to see why they are an excellent choice for building a powerful problem solving platform So whether you re a coding enthusiast looking to sharpen your skills or a business looking to improve your operations don t hesitate to give containers a try you ll be glad you did And remember as the famous quote goes Containers are like Legos for your code so have fun building your own problem solving platform the possibilities are endless 2023-04-30 16:41:16
海外TECH DEV Community Yet Another Newsletter LOL: Blue Skies https://dev.to/nickytonline/yet-another-newsletter-lol-blue-skies-37kd Yet Another Newsletter LOL Blue SkiesAnother week another newsletter Let s get to it Around the WebIf you re on Bluesky I m nickyt online I ve been enjoying the new social network but it s still early days Kudos to the team working on it Wes Bos created a nifty CLI tool for it using the new AT Protocol API You can post to Bluesky see your timeline etc Devon Govett recently mentioned the React Aria NumberField component on Twitter It looks pretty awesome and reminds me I must build something with React Aria New to React Aria It s a library of React Hooks that provides accessible UI primitives for your design system Check it out I really enjoy Jack Herrington s content and he posted a banger of a video recently How To Fix NextJS s N Problem It was a great video and I also discovered a new tool called oha I recommend you check out both Fun StuffThis cracked me up Groan lolWords of Wisdom for the WeekA reminder that we re not productive of the time and that s OK It ebbs and flows Shameless PlugsThis week I got to hang with Mike Hartington Director of Developer Relations at Ionic We built a basic app bootstrapping it with the Ionic CLI demonstrating how you can leverage all your web dev skills and tools Remember to like and subscribe On the stream this week is a doubleheader Todd Libby joins me to discuss Deceptive Patterns amp the FAST framework and then Kevin Ball a k a kball of JSParty fame joins me to discuss Coaching and Why It s Helpful for Engineers Check out the full schedule so you can experience all the great guests I ll be at Remix Conf on May th If you re there don t be shy and come say hi I ll also have some stickers and pins from Netlify I gave my GitHub profile a bit of a cleanup Let me know what you think JobsIf you re a fan of Next js check out the latest Who s hiring thread in the Next js GitHub discussions I post jobs in the iamdeveloper com community plus all other kinds of content as do others If you re looking for another friendly nook of the internet head to discord iamdeveloper com If you liked this newsletter you can subscribe or if RSS is your jam you can also subscribe via RSS 2023-04-30 16:16:12
海外TECH DEV Community How Array.prototype.sort() works? https://dev.to/bekmurzintimur/how-arrayprototypesort-works-3kcn How Array prototype sort works The main reason that I decided to write this article is to explore what lies under the hood of the Array prototype sort function Firefox uses merge sort while Chrome and Safari use Timsort And there s a compelling reason to choose the latter Who developed itTimsort was designed in by Tim Peters primarily for use in the Python programming language The algorithm was so effective that it was later implemented in other well known programming languages such as Java Timsort includes numerous implementation optimizations a few heuristics and some refined tuning Its high level principle is straightforward The array to be sorted is first decomposed greedily into monotonic runs sorted subarrays which are then merged pairwise according to specific rules Comparisons with other sorting algorithmsTimsort outperforms both quicksort and merge sort in various scenarios Basic OverviewTimsort takes advantage of the fact that real world data is often partially sorted The algorithm iterates through the array once to identify already sorted parts called runs These runs should be at least minRun in length which we ll explain later The algorithm examines each element consecutively determining if it is part of an ascending or descending run When it encounters an element not part of the sequence it registers the run and starts a new one If a run s length is less than minRun the algorithm extends the run by adding the next element and sorting the array using Insertion Sort After this loop we have an array consisting of several runs each with run length gt minRun These sorted runs are then intelligently merged Timsort is a stable sorting algorithm order of elements with same value is kept and strives to perform balanced merges a merge that merges runs of similar sizes Insertion SortInsertion sort is a simple method of sorting a list by gradually moving each item to its correct position just like arranging playing cards in your hand Here is insertion sort in action You can look at how it works step by step here Insertion Sort vs Merge SortInsertion Sort excels at sorting partially sorted and small arrays Merge Sort on the other hand aims to call the merge function as few times as possible preferring to merge a small number of large sorted runs This is where the minRun property comes in handy The optimal run length balances the performance of Insertion Sort and the number of merges required The sweet spot typically lies between and MinRun SelectionThe optimal minRun size varies for each array Let s examine a scenario proposed by Tim Peters Suppose we have elements in the array and a minRun of If the data is randomly ordered we ll likely end up with runs each elements long The first runs merge perfectly into a single run of length Now we have two runs with lengths and This requires considerable data movement to put in place those elements The solution is to choose a larger minRun ーin this case ーwhich is more likely to result in runs each with a length of Consequently all merges are perfectly balanced Runs StackTimsort also employs a clever merging pattern For random data it s nearly impossible to find a sequence with more than elements In this case all our runs will likely have the same length and merge performs best when merging runs of equal size However merging them consecutively can lead to problems Imagine we have runs each elements long and we ve merged all but two of them We d have run A with a length of and run B with a length of This is not ideal To avoid this issue we examine the last three runs on the stack let s call them X Y and Z where Z is the length of the most recent and check for these invariants Invariant Z gt Y X Invariant Y gt XIf both invariants hold true the algorithm continues to add runs until one of them fails When this occurs it merges run Y with the lesser of Z and X Merging Z and X directly could compromise stability which ensures that elements with the same value maintain their relative positions after sorting This approach essentially ensures that the largest run is merged last Consider a stack of runs with lengths Timsort will merge the two last runs producing a new one with a length of and keep going making perfect merges much like merging the squares in the game GallopingMerging runs of different lengths is often necessary particularly when data is partially sorted To improve the speed of the merge Tim Peters introduced the galloping technique Typically the merge function has a complexity of O m n where m and n represent the lengths of the two runs It must loop through one of the runs completely Consider the following case we need to merge two arrays in ascending order each containing elements arr arr Should we compare every value from arr to arr before merging the runs Instead we can detect that one of the arrays is consistently winning and trigger galloping That way we move the whole winning portion of the run How can we do that Rather than incrementing by through the winning array we double our increment until the winning streak breaks When it does we use binary search to find the new starting point In our case we determine that arr is winning after the first seven comparisons It s proven that a winning streak of seven comparisons is the best trigger for galloping We move our pointer by then etc In our example the winning streak will never end so we will make log n comparisons All red elements are smaller than blue here Thus they can be moved in a chunk to the final arrayHowever if the winning streak ends we find the largest value in arr that is still smaller than the value under the arr pointer push all elements before it into the resulting array and start again from the pointer in arr SummaryTimsort is ingenious algorithm It combines multiple techniques from different sorts and improves them It has more tricks up to his sleeve than I can cover in one article You can find the JS implementation here And finally Timsort in action Useful linksSources Algorithm overview by Tim Peters himselfWikipediaProof of complexity 2023-04-30 16:07:12
Apple AppleInsider - Frontpage News NHS sends alerts COVID-19 app has shut down in England and Wales https://appleinsider.com/articles/23/04/30/nhs-sends-alerts-covid-19-app-has-shut-down-in-england-and-wales?utm_medium=rss NHS sends alerts COVID app has shut down in England and WalesUsers of the NHS COVID app in England and Wales are no longer able to use the app due to the shutdown of the service on Thursday The NHS COVID app for England and Wales Like many other countries around the world the UK s National Health Service has relied on apps to try and detect and cut down the spread of COVID in the country In an update on Thursday the app stopped working for a large part of the UK Read more 2023-04-30 16:13:39
海外TECH Engadget Apple is reportedly redesigning watchOS around widgets https://www.engadget.com/apple-is-reportedly-redesigning-watchos-around-widgets-162720331.html?src=rss Apple is reportedly redesigning watchOS around widgetsApple is reportedly working on its most significant software overhaul to watchOS in recent memory According to Bloomberg s Mark Gurman the company is redesigning the Apple Watch s user interface to make widgets a “central part of how you will interact with the wearable In describing the new UI Gurman says it brings back elements of the Glances system that was part of the original watchOS while borrowing the “style of widgets Apple introduced alongside iOS last year nbsp He adds the new interface will be “reminiscent of the Siri watch face that the company introduced with watchOS in but will function as an overlay for whatever watch face you wish to use “It s also similar to widget stacks Gurman adds referencing the iOS feature that allows you to scroll through widgets you ve placed on top of one another pic twitter com RTSyWLCirlーMark Gurman markgurman April Simultaneously Apple is reportedly testing a tweak to the Apple Watch s physical buttons With the interface redesign pressing down on the digital crown could launch the operating system s new widgets view instead of taking you to the home screen like the dial currently does with watchOS With the likelihood that the redesign will be jarring for some Gurman speculates Apple plans to make the new interface optional at first Additionally he suggests the overhaul is an admission that an iPhone like app experience “doesn t always make sense on a watch a place where you want as much information as possible with the least amount of poking around With WWDC a little more than a month away it won t be long before Apple shares more information about what Watch users can expect from its wearable s next big software update This article originally appeared on Engadget at 2023-04-30 16:27:20
海外TECH CodeProject Latest Articles C# Events to Awaitable pattern https://www.codeproject.com/Tips/5359923/Csharp-Events-to-Awaitable-pattern awaitable 2023-04-30 16:02:00
ニュース BBC News - Home Critical hospital services can call in striking nurses https://www.bbc.co.uk/news/health-65442143?at_medium=RSS&at_campaign=KARANGA critical 2023-04-30 16:41:44
ニュース BBC News - Home UK arranges extra evacuation flight from Port Sudan on Monday https://www.bbc.co.uk/news/uk-65441191?at_medium=RSS&at_campaign=KARANGA khartoum 2023-04-30 16:19:15
ニュース BBC News - Home Terrorists limited to two boxes of books in prison cells https://www.bbc.co.uk/news/uk-65443483?at_medium=RSS&at_campaign=KARANGA religious 2023-04-30 16:38:46
ニュース BBC News - Home Exeter hopes ended by ruthless La Rochelle https://www.bbc.co.uk/sport/rugby-union/65442176?at_medium=RSS&at_campaign=KARANGA rochelle 2023-04-30 16:17:56

コメント

このブログの人気の投稿

投稿時間:2021-06-17 22:08:45 RSSフィード2021-06-17 22:00 分まとめ(2089件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)