Tutorial by Examples: di

"""PyAudio Example: Play a wave file.""" import pyaudio import wave import sys CHUNK = 1024 if len(sys.argv) < 2: print("Plays a wave file.\n\nUsage: %s filename.wav" % sys.argv[0]) sys.exit(-1) wf = wave.open(sys.argv[1], 'rb') # i...
Relational DatabaseElasticsearchDatabaseIndexTableTypeRow/RecordDocumentColumn Namefield Above table roughly draws an analogy between basic elements of relational database and elasticsearch. Setup Considering Following structure in a relational database: create databse test; use test; crea...
class *model_name*(models.Model): _name = *model_name* @api.model def _configure_sales(self): # Do the configuration here Every time when module will be installed this function will run. Note: If you remove noupdate from xml, function will run on upgrading as well.
The simplest way to include plots in your shinyApp is to use plotOutput in the ui and renderPlot in the server. This will work with base graphics as well as ggPlots library(shiny) library(ggplot2) ui <- fluidPage( plotOutput('myPlot'), plotOutput('myGgPlot') ) server <- function...
animated_android_dialog_box.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:padding="16dp"> &...
You can restrict the directions the user is able to scroll to using the following code: func scrollViewDidScroll(_ scrollView: UIScrollView) { if scrollView.contentOffset.x != 0 { scrollView.contentOffset.x = 0 } } Every time the user scrolls on the x-axis, the scrollView's c...
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context=&quot...
store the cookie with three parts. function onLogin($user) { $token = GenerateRandomToken(); // generate a token, should be 128 - 256 bit storeTokenForUser($user, $token); $cookie = $user . ':' . $token; $mac = hash_hmac('sha256', $cookie, SECRET_KEY); $cookie .= ':' . $mac...
I get the file path from document directory and read that file in chunks of 1024 and save (append) to NSMutableData object or you can directly write to socket. // MARK: - Get file data as chunks Methode. func getFileDataInChunks() { let doumentDirectoryPath = NSSearchPathForDirectoriesI...
You can show username for autenticated users <div sec:authorize="isAuthenticated()"> Welcome, <span sec:authentication="name">Username</span> </div>
The sec:authorize attribute renders its content when the attribute expression is evaluated to true <div sec:authorize="hasRole('ROLE_ADMIN')"> Content for administrators </div> <div sec:authorize="hasRole('ROLE_USER')"> Content for users </div&g...
Define a custom loss function: import keras.backend as K def euclidean_distance_loss(y_true, y_pred): """ Euclidean distance loss https://en.wikipedia.org/wiki/Euclidean_distance :param y_true: TensorFlow/Theano tensor :param y_pred: TensorFlow/Theano ...
Developers often need to design web sites that allow users to upload a CSV file. Usually there is no reason to save the actual CSV file since the data will processed and/or stored in a database once uploaded. However, many if not most, PYTHON methods of parsing CSV data requires the data to be rea...
For really huge search results, you can use dedicated Map/Reduce script. It is much more inconvenient, but sometimes unavoidable. And sometimes could be very handy. The trick here is, that in Get Input Data stage, you can provide to the NS engine not the actual data (i.e. script result), but just t...
#include <opencv2/opencv.hpp> #include using namespace cv; using namespace std; int main(int argc, char** argv) { Mat image; image = imread("C:\Users\Development\Documents\Visual Studio 2013\Projects\ImageIn.bmp", CV_LOAD_IMAGE_GRAYSCALE); // Read the file if (!image.data)...
You can re-set variables within media queries and have those new values cascade wherever they are used, something that isn't possible with pre-processor variables. Here, a media query changes the variables used to set up a very simple grid: HTML <div></div> <div></div> &...
Suppose this struct is defined and compiled with a 32 bit compiler: struct test_32 { int a; // 4 byte short b; // 2 byte int c; // 4 byte } str_32; We might expect this struct to occupy only 10 bytes of memory, but by printing sizeof(str_32) we see it uses 12 by...
This example will help to have the Edit text with the icon at the right side. Note: In this just I am using setCompoundDrawablesWithIntrinsicBounds, So if you want to change the icon position you can achieve that using setCompoundDrawablesWithIntrinsicBounds in setIcon. public class MKEditTe...
This method will help to get the Java string from C++ string. jstring getJavaStringFromCPPString(JNIEnv *global_env, const char* cstring) { jstring nullString = global_env->NewStringUTF(NULL); if (!cstring) { return nullString; } jclass strC...
Docs: extending elements, inherited templates. Instead of Polymer.Element, a custom element can extend a different element: class ParentElement extends Polymer.Element { /* ... */ } class ChildElement extends ParentElement { /* ... */ } To change or add to the parent's template, over...

Page 160 of 164