Tutorial by Examples: code

def make_unicode(data): if type(data) != unicode: data = data.decode('utf-8') return data else: return data
1. Install GLFW First step is to create an OpenGL window. GLFW is an Open Source, multi-platform library for creating windows with OpenGL, to install GLFW first download its files from www.glfw.org Extract the GLFW folder and its contents will look like this Download and install CMake to buil...
To comment on the same line as the code you can use &:: or &rem. You can also use && or || to replace &. Example : @echo off echo This is a test &::This is a comment echo This is another test &rem This is another comment pause A curiosity: SET command allows limit...
private static final String TAG = "IntentBitmapFetch"; private static final String COLON_SEPARATOR = ":"; private static final String IMAGE = "image"; @Nullable public Bitmap getBitmap(@NonNull Uri bitmapUri, int maxDimen) { InputStream is = context.getConten...
QRCodeReaderView implements an Android view which show camera and notify when there's a QR code inside the preview. It uses the zxing open-source, multi-format 1D/2D barcode image processing library. Adding the library to your project Add QRCodeReaderView dependency to your build.gradle dependen...
Shortcodes are useful when you want to be able add more complex elements inline into the normal content editor. A shortcode in it's simplest for would look like this: function my_shortcode( ){ return "This is a shortcode"; } add_shortcode( 'my_shortcode', 'my_shortcode' ); It w...
Here is an example of a simple button short code: <?php function my_button_shortcode( $atts ) { // Parse the input attributes and assgn default values for the // attributes that are not specified on the shortcode $a = shortcode_atts( array( 'id' => '', 'ur...
function sumofsins1(n::Integer) r = 0 for i in 1:n r += sin(3.4) end return r end function sumofsins2(n::Integer) r = 0.0 for i in 1:n r += sin(3.4) end return r end Timing the above two functions shows major...
app.use() and middleware can be used for "before" and a combination of the close and finish events can be used for "after". app.use(function (req, res, next) { function afterResponse() { res.removeListener('finish', afterResponse); res.removeListener('clos...
esc_html should be used anytime we're outputting data inside HTML code. <h4><?php echo esc_html( $title ); ?></h4>
esc_js() is intended to be used for inline JS, inside a tag attribute. For data inside a <script> tag use wp_json_encode(). <input type="text" onfocus="if( this.value == '<?php echo esc_js( $fields['input_text'] ); ?>' ) { this.value = ''; }" name="name&quot...
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...
You can use extensions for reference View, no more boilerplate after you created the views. Original Idea is by Anko Library Extensions inline fun <reified T : View> View.find(id: Int): T = findViewById(id) as T inline fun <reified T : View> Activity.find(id: Int): T = findViewById(i...
You may wish to update your custom setting's during the execution of your code, to switch off validation or workflow rules. In the below code, I have created a Schedulable Apex Class which will update the Close Date of any Opportunities whose Close Date is less than or equal to 6 days from the curr...
Xamarin sturio opens Xib file and Storyboards by default in the Xamarin Designer. User can right click on the file and Open With -> `Xcode Interface Builder'
After you got the Location object from FusedAPI, you can easily acquire Address information from that object. private Address getCountryInfo(Location location) { Address address = null; Geocoder geocoder = new Geocoder(getActivity(), Locale.getDefault()); String errorMessage; Li...
One helpful case is to have the action run a block of code. In Swift: let node = SKSpriteNode(imageNamed: "image") let actionBlock = SKAction.runBlock({ //Do what you want here if let gameScene = node.scene as? GameScene { gameScene.score += 5 } }) node.runActi...
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...
The simplest shortcode is the self-closing one. We’re going to create a simple link to our Twitter account, and then add it in a blog post. All the code goes in functions.php, which is located in /wp-content/themes/your-theme/. If you don’t have one, just create it and put the code in it. <?php...
Creating a self-closing shortcode with parameters <?php function button_shortcode( $type ) { extract( shortcode_atts( array( 'type' => 'value' ), $type ) ); // check what type user entered switch ($type) { case 'twitter': ...

Page 12 of 21