Installation
pip install Flask-SQLAlchemy
Simple Model
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80))
email = db.Column(db.String(120), unique=True)
The code example above shows a simple Flask-SQLAlchemy model, we can add an ...
This following example is created by user Michael Dillon from this answer.
Consider the following script:
@set @junk=1 /*
@echo off
cscript //nologo //E:jscript %0 %*
goto :eof
*/
//JScript aka Javascript here
This script snippet does:
Execute the cscript command which calls itsel...
As mentioned here, the old-school method to run another script is by using temporary files. Simple echo it into a file and then run it(and remove it optionally).
Here's the basic concept:
@echo off
echo //A JS Comment > TempJS.js
echo //Add your code>>TempJS.js
cscript //nologo //e...
from flask_wtf import FlaskForm
from wtforms import StringField, IntegerField
from wtforms.validators import DataRequired
class MyForm(FlaskForm):
name = StringField('name', validators=[DataRequired()])
age = InterField('age', validators=[DataRequired()])
To render the template you...
You can save a canvas to an image file by using the method canvas.toDataURL(), that returns the data URI for the canvas' image data.
The method can take two optional parameters canvas.toDataURL(type, encoderOptions): type is the image format (if omitted the default is image/png); encoderOptions is ...
My laptop is having Windows 10. Here i am giving steps that you can follow to test and learn Ansible.
SOME THEORY
For Ansible you need a Control Machine and a host(or hosts) to run the Playbook.
Control Machine should be Linux based or MacOS(windows not allowed) and need Python (2.6 or higher v...
It is a powerful and mostly used keyword in Ansible to run Playbook using Ad-Hoc commands
Example: ansible-playbook demo.yml
Further Reading on ansible-plabook
The following command displays output only on the screen (stdout).
$ ls
The following command writes the output only to the file and not to the screen.
$ ls > file
The following command (with the help of tee command) writes the output both to the screen (stdout) and to the file.
$ ls | ...
You can also use tee command to store the output of a command in a file and redirect the same output to another command.
The following command will write current crontab entries to a file crontab-backup.txt and pass the crontab entries to sed command, which will do the substituion. After the substi...
Here we will create a rest APi which will take file object as a
multipart parameter from front end and upload it to S3 bucket using
java rest API.
Requirement :- secrete key and Access key for s3 bucket where you wanna upload your file.
code:-
DocumentController.java
@RestController
@Requ...
A typical example of the implementation of a Looper thread given by the official documentation uses Looper.prepare() and Looper.loop() and associates a Handler with the loop between these calls.
class LooperThread extends Thread {
public Handler mHandler;
public void run() {
Lo...
A HandlerThread can be used to start a thread with a Looper. This looper then can be used to create a Handler for communications with it.
HandlerThread thread = new HandlerThread("thread-name");
thread.start();
Handler handler = new Handler(thread.getLooper());
Java StringWriter class is a character stream that collects output from string buffer, which can be used to construct a string.
The StringWriter class extends the Writer class.
In StringWriter class, system resources like network sockets and files are not used, therefore closing the StringWriter i...