#!/usr/bin/env python
"""
An annotated simple socket server example in python.
WARNING: This example doesn't show a very important aspect of
TCP - TCP doesn't preserve message boundaries. Please refer
to http://blog.stephencleary.com/2009/04/message-framing.html
before adaptin...
#!/usr/bin/env python
"""
An annotated simple socket client example in python.
WARNING: This example doesn't show a very important aspect of
TCP - TCP doesn't preserve message boundaries. Please refer
to http://blog.stephencleary.com/2009/04/message-framing.html
before adaptin...
Passwords should never be stored as plain text! They should be hashed with a randomly generated salt (to defend against rainbow table attacks) using a slow password hashing algorithm. A high number of iterations (> 10k) can be used to slow down brute force attacks. A delay of ~100ms is acceptable...
Apart from primitives, the Explicit Layout structs (Unions) in C#, can also contain other Structs. As long as a field is a Value type and not a Reference, it can be contained in a Union:
using System;
using System.Runtime.InteropServices;
// The struct needs to be annotated as "Explici...
To change the execution policy for the default scope (LocalMachine), use:
Set-ExecutionPolicy AllSigned
To change the policy for a specific scope, use:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy AllSigned
You can suppress the prompts by adding the -Force switch.
Often you might need to execute an unsigned script that doesn't comply with the current execution policy. An easy way to do this is by bypassing the execution policy for that single process. Example:
powershell.exe -ExecutionPolicy Bypass -File C:\MyUnsignedScript.ps1
Or you can use the shorthan...
Getting the effective execution policy for the current session:
PS> Get-ExecutionPolicy
RemoteSigned
List all effective execution policies for the current session:
PS> Get-ExecutionPolicy -List
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined...
Get information about the Authenticode signature from a signed script by using the Get-AuthenticodeSignature-cmdlet:
Get-AuthenticodeSignature .\MyScript.ps1 | Format-List *
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...
Dynamic SQL enables us to generate and run SQL statements at run time. Dynamic SQL is needed when our SQL statements contains identifier that may change at different compile times.
Simple Example of dynamic SQL:
CREATE PROC sp_dynamicSQL
@table_name NVARCHAR(20),
@col_name NVARCHAR(2...
Sometimes a new Java programmer will write code like this:
public void check(boolean ok) {
if (ok == true) { // Note 'ok == true'
System.out.println("It is OK");
}
}
An experienced programmer would spot that as being clumsy and want to rewrite it as:
publ...
The normal Java classloaders look for classes first in the bootstrap classpath, before checking for extensions and the application classpath. By default, the bootstrap classpath consists of the "rt.jar" file and some other important JAR files that are supplied by the JRE installation. Th...
Sprite animation consists in showing an existing sequence of images or frames.
First import a sequence of images to the asset folder. Either create some images from scratch or download some from the Asset Store. (This example uses this free asset.)
Drag every individual image of a single animati...
Pre-requisites:
cx_Oracle package - See here for all versions
Oracle instant client - For Windows x64, Linux x64
Setup:
Install the cx_Oracle package as:
sudo rpm -i <YOUR_PACKAGE_FILENAME>
Extract the Oracle instant client and set environment variables as:
ORACLE_HOME=&...
In features/step_definitions/documentation.rb:
When /^I go to the "([^"]+)" documentation$/ do |section|
path_part =
case section
when "Documentation"
"documentation"
else
raise "Unknown documentation section: #{section...
If you are only adding new rows in your RDBMS (not updating existing data)
You need two additional parameters:
--check-column : A column name that should be checked for newly appended data. Integer would be a suitable data type for this column.
--last-value : The last value that successfully im...
If you are adding new rows and updating existing data.
You need two additional parameters:
--check-column : A column name that should be checked for newly appended and updated data. date, time, datetime and timestamp are suitable data types for this column.
--last-value : The last value that su...
Local variables - Those declared within a procedure (subroutine or function) of a class (or other structure). In this example, exampleLocalVariable is a local variable declared within ExampleFunction():
Public Class ExampleClass1
Public Function ExampleFunction() As Integer
Dim exa...