Tutorial by Examples

To write a new .zip file: System.IO.Compression System.IO.Compression.FileSystem using (FileStream zipToOpen = new FileStream(@"C:\temp", FileMode.Open)) { using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Update)) { ZipArchiveEntry readmeEntry...
A ThreadPool is an ExecutorService that executes each submitted task using one of possibly several pooled threads, normally configured using Executors factory methods. Here is a basic code to initialize a new ThreadPool as a singleton to use in your app: public final class ThreadPool { priv...
One of the features that we can use with Threadpools is the submit() method which allow us to know when the thread as finish his work. We can do this thanks to the Future object, which return us an object from the Callable that we can use to our own objetives. Here is an example about how to use th...
Another good practice to check when our threads have finished without block the thread waiting to recover the Future object from our Callable is to create our own implemetation for Runnables, using it together with the execute() method. In the next example, I show a custom class which implements Ru...
We use ExecutorService to assign threads from the internal thread pool or create them on-demand to perform tasks. Each ExecutorService has an ThreadFactory, but The ExecutorService will use always a default one if we don't set a custom one. Why we should do this? To set a more descriptive thread...
@Test annotation can be applied to any class or method. This annotation marks a class or a method as part of the test. @Test at method level - mark annotated method as test method @Test at class level The effect of a class level @Test annotation is to make all the public methods of the class ...
A simple way to create a Hello World program: import wx app = wx.App(redirect=False) frame = wx.Frame(parent=None, id=wx.ID_ANY, title='Hello World') frame.Show() app.MainLoop() Output: A more typical example would be to subclass wx.Frame: import wx class MyFrame(wx.Frame): def...
It is possible to change the opacity of a color with fade() function. fade() takes 2 parameters: a color opacity (in %) Example: @elegant: #eeffgg; .light-elegant { background-color: fade(@elegant, 20%); } <div class="light-elegant"> I have a 20% elegant...
Clustered column store index can be rebuilt if you have a lot of deleted rows: ALTER INDEX cci ON Products REBUILD PARTITION = ALL Rebuilding CLUSTERED COLUMNSTORE will "reload" data from the current table into new one and apply compression again, remove deleted rows, etc. You can re...
Is good practice to resist the temptation of doing the delete action in the get request. It would be a huge security error, it has to be done always in the post method. // GET: Student/Delete/5 public ActionResult Delete(int? id) { // it good practice to consider that things...
Sometimes, it can be useful to import functions and structs relatively without having to use something with its absolute path in your project. To achieve this, you can use the module super, like so: fn x() -> u8 { 5 } mod example { use super::x; fn foo() { println!(...
Kubernetes was originally developed by Google to power their Container Engine. As such, Kubernetes clusters are a first class citizen at Google. Creating a Kubernetes cluster in the container engine requires gcloud command from the Google Cloud SDK. To install this command locally, use one of the f...
A Kubernetes cluster is controlled using the kubectl command. The method of configuring kubectl depends on where Kubernetes is installed. Google Cloud (Container Engine) To install kubectl using the Google Cloud SDK: gcloud components install kubectl To configure kubectl to control an existing...
The following example will return the byte[] data of a zipped file containing the files provided to it, without needing access to the file system. public static byte[] ZipFiles(Dictionary<string, byte[]> files) { using (MemoryStream ms = new MemoryStream()) { using (ZipArc...
This example gets a listing of files from the provided zip archive binary data: public static Dictionary<string, byte[]> GetFiles(byte[] zippedFile) { using (MemoryStream ms = new MemoryStream(zippedFile)) using (ZipArchive archive = new ZipArchive(ms, ZipArchiveMode.Read)) ...
The following is the default code snippet for the BundleConfig.cs file. using System.Web.Optimization; public class BundleConfig { // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725 public static void RegisterBundles(BundleCollection bundles...
First why we should use depedency injection in our code ? We want to decouple other components from other classes in our program. For example we have class AnimalController which have code like this : public class AnimalController() { private SantaAndHisReindeer _SantaAndHisReindeer = new San...
autodie allows you to work with files without having to explicitly check for open/close failures. Since Perl 5.10.1, the autodie pragma has been available in core Perl. When used, Perl will automatically check for errors when opening and closing files. Here is an example in which all of the lines ...
VI snippets are like Screenshots of a Block Diagram, with one important difference. They can be opened in LabVIEW to reconstruct the orginal program. They are saved in the common .PNG format so they can be used like normal pictures e.g. in forums and on StackOverflow. To create a VI snippet mark th...
Let's say that you have exam scores for several exams and you want to divide them into quartiles per exam. -- Setup data: declare @values table(Id int identity(1,1) primary key, [Value] float, ExamId int) insert into @values ([Value], ExamId) values (65, 1), (40, 1), (99, 1), (100, 1), (90, 1), ...

Page 914 of 1336