Tutorial by Examples: an

The most effective way to resolve curl to a different server is to use the --resolve option. This option will insert the address into curl's DNS cache, so it will effectively make curl believe that's the address it got when it resolved the name. Like so: curl --resolve eaxmple.com:80:1.2.3.4 http:...
The "Host:" header is a normal way an HTTP client tells the HTTP server which server it speaks to. By passing custom modified "Host:" header you can have the server respond with the content of the site, even if you didn't actually connect to the host name. For example, if you ha...
from django.contrib.auth.models import User class UserAdmin(admin.ModelAdmin): list_display = ('email', 'first_name', 'last_name') list_filter = ('is_staff', 'is_superuser') admin.site.unregister(User) admin.site.register(User, UserAdmin) We need to unregister before regis...
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&...
Declaring a DLL procedure to work with different VBA versions: Option Explicit #If Win64 Then Private Declare PtrSafe Sub xLib "Kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long) #ElseIf Win32 Then Private Declare Sub apiSleep Lib "Kernel32" Ali...
interface Foo { fun example() } class Bar { fun example() { println("Hello, world!") } } class Baz(b : Bar) : Foo by b Baz(Bar()).example() The example prints Hello, world!
val a = arrayOf(1, 2, 3) // creates an Array<Int> of size 3 containing [1, 2, 3].
val a = Array(3) { i -> i * 2 } // creates an Array<Int> of size 3 containing [0, 2, 4]
val a = arrayOfNulls<Int>(3) // creates an Array<Int?> of [null, null, null] The returned array will always have a nullable type. Arrays of non-nullable items can't be created uninitialized.
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 ...
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 ...
When using Django as a web service framework, the package django-log-request-id can be used to parse and log request IDs. Settings MIDDLEWARE_CLASSES = ( 'log_request_id.middleware.RequestIDMiddleware', # ... other middleware goes here ) LOGGING = { 'version': 1, 'disable_e...
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 window resize events can fire in response to the movement of the user's input device. When you resize a canvas it is automatically cleared and you are forced to re-render the content. For animations you do this every frame via the main loop function called by requestAnimationFrame which does its...
npm init This will initialize a new NPM project for you - just press enter until it stops asking you questions. Now you'll notice that you have a new file called package.json. This file will, among other things, keep track of which packages or modules you've installed in your project.
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...
By default tee command overwrites the file. You can instruct tee to append to the file using the –a option as shown below. $ ls | tee –a file
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) posts = db.relationship('Post', backref='user') class Post(db.Model): id = db.Column(db.Integer,...

Page 295 of 307