Tutorial by Examples: codes

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...
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...
def make_unicode(data): if type(data) != unicode: data = data.decode('utf-8') return data else: return data
Being able to understand Error/Exit codes is a fundamental skill for developers on Window's machine. Yet for many, the cryptic hexadecimal code that can be produced on an application exiting with on error can prove to be time consuming and painstaking process for the developer to track down and isol...
WordPress shortcodes were introduced in 2.5 Here is come example of shortcode [button] to use shortcode direct into theme you have to use do_shortcode() <?php echo do_shortcode('[button]'); ?> To customize the button, we could simply add something like: [button type="twitter&qu...
By default, WordPress does not support shortcodes within Sidebar Widgets. It only expands the shortcodes within the content of a Post, Page, or custom post type. To add shortcode support to sidebar widgets, you can install a plugin, or use the below code: add_filter( 'widget_text', 'shortcode_unaut...
Go to Codeship.com and create an account (or login) Create a new project Import your project via Github or Bitbucket On the screen "Configure Your Tests" use these commands: Select "I want to create my own custom commands" from the "Select your technology to prepop...
Append the following command to the Codeship setup commands: meteor npm run mgp Now, we need to give Codeship access to these private repositories. There is a Codeship documentation article describing this process in detail but here are the steps that you have to take for Github: Create a new...
The hash codes produced by GetHashCode() method for built-in and common C# types from the System namespace are shown below. Boolean 1 if value is true, 0 otherwise. Byte, UInt16, Int32, UInt32, Single Value (if necessary casted to Int32). SByte ((int)m_value ^ (int)m_value << 8); Char...
Most examples of a function returning a value involve providing a pointer as one of the arguments to allow the function to modify the value pointed to, similar to the following. The actual return value of the function is usually some type such as an int to indicate the status of the result, whether ...
PS> $LastExitCode PS> $? PS> $Error[0] These are built-in PowerShell variables that provide additional information about the most recent error. $LastExitCode is the final exit code of the last native application that was executed. $? and $Error[0] is the last error record that was gene...
This is just a small hack for those who use self-defined functions often. Type "fun" RStudio IDE and hit TAB. The result will be a skeleton of a new function. name <- function(variables) { } One can easily define their own snippet template, i.e. like the one below ...
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() .detectDiskWrites() .penaltyLog() //Logs a message to LogCat .build())
Paste this snippet somewhere in the http {} Block; or place it in it's own file in the /etc/nginx/conf.d/ folder. Also see the official docs for logging to syslog. # # Access Log # log_format fmt_syslog '[$time_local] $status $remote_addr $http_host "$request" $body_bytes_sent $reque...
Native string functions are mapped to single byte functions, they do not work well with Unicode. The extentions iconv and mbstring offer some support for Unicode, while the Intl-extention offers full support. Intl is a wrapper for the facto de standard ICU library, see http://site.icu-project.org fo...
It's possible to have your own custom code styles, share them with other team members and use a shortcut to auto format the code in a file. To create your own custom code style, go to: Preferences -> Editor -> Code Style There are some general code style settings here. You can also select ...
Function definition: def run_training(train_X, train_Y): Inputs variables: X = tf.placeholder(tf.float32, [m, n]) Y = tf.placeholder(tf.float32, [m, 1]) Weight and bias representation W = tf.Variable(tf.zeros([n, 1], dtype=np.float32), name="weight") b = tf.Variable(tf.zeros([...
Public: public val name = "Avijit" Private: private val name = "Avijit" Protected: protected val name = "Avijit" Internal: internal val name = "Avijit"
I wrote a simple C code foo.c int main() { int i = 0; int j = 0; for (i = 0; i < 5; i++) { j = i + 1; } return 0; } When compiled with -O0 i.e. by disabling all compiler optimizations $ gcc -o foo.S foo.c -O0 -S I got this: .file "foo.c&...
user.model.js var mongoose = require('mongoose') const UserSchema = new mongoose.Schema({ name: String }) const User = mongoose.model('User', UserSchema) module.exports = User; user.routes.js var express = require('express'); var router = express.Router(); var UserController...

Page 2 of 2