Tutorial by Examples: code

The FaultException can also includes a FaultCode, that is a string data you can use to pass additional information, so the client can be able to distinguish different exceptions: try { // your service logic here } catch (Exception ex) { throw new FaultException("There was a proble...
It took me a while to get this right, so I decided to share a solution because it might save someone else several days of trial and error. The problem: I want to be able to enable/disable WCF tracing in my C# .NET application and choose the trace output filename. I don't want users editing the .con...
TextViewPlus.java: public class TextViewPlus extends TextView { private static final String TAG = "TextView"; public TextViewPlus(Context context) { super(context); } public TextViewPlus(Context context, AttributeSet attrs) { super(context, attrs)...
Every Python statement in Vim should be prefixed with the :python command, to instruct Vim that the next command is not Vimscript but Python. To avoid typing this command on each line, when executing multi-line Python code, it is possible to instruct Vim to interpret the code between two marker exp...
When signing personal scripts or when testing code signing it can be useful to create a self-signed code signing certificate. 5.0 Beginning with PowerShell 5.0 you can generate a self-signed code signing certificate by using the New-SelfSignedCertificate-cmdlet: New-SelfSignedCertificate -Friendl...
Utilizing .Net System.Security.Cryptography.HashAlgorithm namespace to generate the message hash code with the algorithms supported. $example="Nobody expects the Spanish Inquisition." #calculate $hash=[System.Security.Cryptography.HashAlgorithm]::Create("sha256").ComputeHas...
In this exemple, we want to execute code which is stored in a string format. # the string str <- "1+1" # A string is not an expression. is.expression(str) [1] FALSE eval(str) [1] "1+1" # parse convert string into expressions parsed.str <- parse(text="1+1...
Consider the following partial example: import com.example.somelib.*; import com.acme.otherlib.*; public class Test { private Context x = new Context(); // from com.example.somelib ... } Suppose that when when you first developed the code against version 1.0 of somelib and versi...
JAXB can be used to generate classes from an model defined in XSD. It will then be possible to read XML document made against this XSD directly as java instances and inversly save these instances as XML document. Take the following XSD saved in a file named SimpleModel.xsd <?xml version="...
If you want to execute synchronous code asynchronous (for example CPU extensive calculations), you can use Task.Run(() => {}). public async Task DoStuffAsync() { await DoCpuBoundWorkAsync(); } private async Task DoCpuBoundWorkAsync() { await Task.Run(() => { fo...
add_filter( 'widget_text', 'shortcode_unautop' ); add_filter( 'widget_text', 'do_shortcode' );enter code here Add this to a plugin or the functions.php file to enable shortcodes in widgets. The code first stops WordPress turning line breaks into paragraph tags and then lets shortcodes to parse f...
First and foremost you should be able to find the bottleneck of your script and note that no optimization can compensate for a poor choice in data structure or a flaw in your algorithm design. Secondly do not try to optimize too early in your coding process at the expense of readability/design/quali...
1)First go through Paypal Developer web site and create an application. 2)Now open your manifest file and give the below permissions <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"...
Regex to match postcodes in UK The format is as follows, where A signifies a letter and 9 a digit: FormatCoverageExampleCellCellAA9A 9AAWC postcode area; EC1–EC4, NW1W, SE1P, SW1EC1A 1BBA9A 9AAE1W, N1C, N1PW1A 0AXA9 9AA, A99 9AAB, E, G, L, M, N, S, WM1 1AE, B33 8THAA9 9AA, AA99 9AAAll other postco...
If your code is running behind a proxy and you know the end point, you can set this information in your code. requests accepts a proxies parameter. This should be a dictionary that maps protocol to the proxy URL. proxies = { 'http': 'http://proxy.example.com:8080', 'https': 'http://securepro...
Xcode by itself has quite a few good tools built in, but sometimes you just want to change a specific behavior or create a convenience shortcut. That's why there's Alcatraz. Installation curl -fsSL https://raw.githubusercontent.com/supermarin/Alcatraz/deploy/Scripts/install.sh | sh Throw this ...
The pattern can be illustrated by the following pseudocode: product = new Product() product.name = "Some Book" product.price = 123.45 product.save() The following SQL would be a result: INSERT INTO products (name, price) VALUES ('Some Book', 123.45);
Project is following the structure from the Angular2 Quickstart guide here. RootOfProject | +-- app | |-- app.component.ts | |-- main.ts | |-- pipeUser.component.ts | \-- sanitize.pipe.ts | |-- index.html |-- main.html |-- pipe.html main.ts import { bootstrap } from '@angu...
If you have code (a routine) you want to execute under a specific (constraint) context, you can use dependency injection. The following example shows the constraint of executing under an open SSL connection. This first part would be in your library or framework, which you won't expose to the client...
If you have a directory with existing source files, you can use qmake with the -project-option to create a project file. Let's assume, the folder MyProgram contains the following files: main.cpp foo.h foo.cpp bar.h bar.cpp subdir/foobar.h subdir/foobar.cpp Then by calling qmake -projec...

Page 11 of 21