Posts

Showing posts from February, 2017

Using Read Function In C Code Example

Example: read files in c # include <stdio.h> int main ( ) { FILE * in = fopen ( "name_of_file.txt" , "r" ) ; char c ; while ( ( c = fgetc ( in ) ) != EOF ) putchar ( c ) ; fclose ( in ) ; return 0 ; }

Aes Encryption Example Python

Example: python AES from Crypto . Cipher import AES import binascii , os import random , string iv = os . urandom ( 16 ) aes_mode = AES . MODE_CBC key = '' . join ( random . choice ( string . ascii_uppercase + string . ascii_lowercase + string . digits ) for _ in range ( 16 ) ) print ( key ) encryptor = AES . new ( key , aes_mode , iv ) def aes_encrypt ( plaintext ) : plaintext = convert_to_16 ( plaintext ) ciphertext = encryptor . encrypt ( plaintext ) return ciphertext def convert_to_16 ( plaintext ) : #Overcome the drawback of plaintxt size which should be multiple of len(iv) add = 16 - ( len ( plaintext ) % 16 ) return ( plaintext + ' ' * add ) Encrypted = aes_encrypt ( 'Jaisal ' ) print ( "Encrypted message :" , Encrypted )

Canvas Api Python Pypi Code Example

Example 1: canvas api python pypi #install canvas api pip install canvasapi Example 2: canvas api python pypi #install canvas api #pip install canvasapi # Import the Canvas class from canvasapi import Canvas # Canvas API URL API_URL = "https://example.com" # Canvas API key API_KEY = "p@ $$ w0rd" # Initialize a new Canvas object canvas = Canvas ( API_URL, API_KEY )

Types Of Inheritance Leads To Diamond Problem Code Example

Example: Diamond inheritance The "diamond problem" ( sometimes referred to as the "Deadly Diamond of Death" ) is an ambiguity that arises when two classes B and C inherit from A , and class D inherits from both B and C If there is a method in A that B and C have overridden , and D does not override it , then which class of the method does D inherit : that of B , or that of C ?

Debian Server Iso Download Code Example

Example 1: download debian 505 a1522daa30d77f4fa5acd4fa3d8c5e1a1cbb4 debian - 10.7 .0 - amd64 - netinst . iso 75088471 b359cd21635afe427a1598ce111dfc41 debian - 10.7 .0 - amd64 - xfce - CD - 1. iso 66 bf9321fcda7cc32040bf644a8a714d9b62adbe debian - edu - 10.7 .0 - amd64 - netinst . iso 5 b326dc3fd2e6c1b686dfa16b0b6d83e81bc5455 debian - mac - 10.7 .0 - amd64 - netinst . iso Example 2: download debian -- -- - BEGIN PGP SIGNATURE -- -- - iQIzBAABCAAdFiEE35ucSeqpKYQyWJ122ofoDWKUvpsFAl / MN + AACgkQ2ofoDWKU vpuPRg / + P / Lc7hlQGGt9a9aCxxikMmLqnsaEi7w0LkvOxzb9SSvRkc55xv / uSwJ / u + G6gezVGctMPTHEXgt19b4jOpw + xxyqkLIQ0MZzzGNOkXbP5chaie + IFxWXBXiI ybP1sixHnpTW1LfyUK6sA / + ayZMNoYb3VIlfVyYXgRzoG7qCFDkhu + WnsALESCG + 1 ffZBgEqA24XkKjp1cDUzmxy9ZvtRIlSiV3rWq0opCyzhYFI44GNZXatDd4jyjOH bgT / LhUPj / dFISFOBYEGL5jWwl + nZP3k6k3JUU30YXlisAu4JLA08UXdzIpgHjCf VRn6oWlx8Gs0Zi19mZ6giaG / zDy4EuHZP0MvQeD53ixXJb3MlLc0zAhYGKnpBzuV R90W3WcbNfu0DTCVQvgtaOQG + XUMlsXB8zGl9cjpUYsKYlceWc5xsVY

Avatar: The Last Airbender Movie 2 Code Example

Example 1: avatar the last airbender The best tv show! Example 2: avatar the last airbender what innocent ibex said

Bootstrap 4 Align Center Vertically Code Example

Example 1: bootstrap vertical align < div class = " d-flex align-items-start " > ... </ div > < div class = " d-flex align-items-end " > ... </ div > < div class = " d-flex align-items-center " > ... </ div > < div class = " d-flex align-items-baseline " > ... </ div > < div class = " d-flex align-items-stretch " > ... </ div > Example 2: centralize div bootstrap < div class = " row align-items-center justify-content-center " > < div class = " col " > This will be centered vertically and horizontally </ div > </ div > Example 3: bootstrap center text vertically < div class = ”row” > < div class = ”col-6 align-self-center” > < div class = ”card card-block” > Center </ div > </ div > </ div > Example 4: bootstrap div vertical center < d

Best Lightweight Web Server (only Static Content) For Windows

Answer : You can use Python as a quick way to host static content. On Windows, there are many options for running Python, I've personally used CygWin and ActivePython. To use Python as a simple HTTP server just change your working directory to the folder with your static content and type python -m SimpleHTTPServer 8000 , everything in the directory will be available at http:/localhost:8000/ Python 3 To do this with Python, 3.4.1 (and probably other versions of Python 3), use the http.server module: python -m http.server <PORT> # or possibly: python3 -m http.server <PORT> # example: python -m http.server 8080 On Windows: py -m http.server <PORT> Have a look at mongoose: single executable very small memory footprint allows multiple worker threads easy to install as service configurable with a configuration file if required The smallest one I know is lighttpd. Security, speed, compliance, and flexibility -- all of these describe ligh

Apache Is Not Running From XAMPP Control Panel ( Error: Apache Shutdown Unexpectedly. This May Be Due To A Blocked Port)

Answer : There are many possible answers for this problem. The most common and most likely is that you're running another program which is blocking port 80 or 443. If you've installed Skype, then you've found your problem! Change apache's port settings to 81 and apache will work. There's a good tutorial on that To check this you can open up your command line by clicking the start menu, and typing 'cmd', and enter the command netstat -nab this wil return a list of programs that will vaguely resemble this pattern [someprogram.exe] UDP [fe80::numbers:numbers:numbers:numbers%numbers]:portnumber You need to find a line (or lines) ending in :80 and terminate them in order to start apache. If there is no line ending in :80, there are more things you can do. First, navigate to xampp's directory (default is c:\xampp) and double click apache_start.bat. This will open up a comand line and return more detailed errors about why apache can

Button Colors In Bootstrap 4 Code Example

Example 1: bootstarp btn colors < button type = "button" class = "btn btn-primary" > Blue < /button > < button type = "button" class = "btn btn-secondary" > Grey < /button > < button type = "button" class = "btn btn-success" > Green < /button > < button type = "button" class = "btn btn-danger" > Red < /button > < button type = "button" class = "btn btn-warning" > Yellow < /button > < button type = "button" class = "btn btn-info" > Ligth blue < /button > < button type = "button" class = "btn btn-light" > White < /button > < button type = "button" class = "btn btn-dark" > Black < /button > < button type = "button" class = "btn btn-link" > White with blue text < /button > Example 2:

Click Event For WPF Image

Answer : Just add a MouseDown (or MouseLeftButtonDown as suggested) event to your image like so <Image x:Name=aPicture Source="mypic.jpg" MouseDown="aPicture_MouseDown"/> // or <Image x:Name=aPicture Source="mypic.jpg" MouseLeftButtonDown="aPicture_MouseDown"/> which should add this to your code behind private void aPicture_MouseDown(object sender, MouseEventArgs e) { //do something here } In WPF each control has its default template (how it looks) but you can easily change these templates and make controls look like you want. This makes it easier to pick control by its functionality and make it look like you want. In your case you want Click so you choose Button and change its Template <Window ...> <Window.Resources> <Style TargetType="{x:Type Button}" x:Key="ImageButtonStyle"> <Setter Property="Template"> <Setter.Value&g

Braket Notation In LaTeX

Image
Answer : There is the physics package: \documentclass{article} \usepackage{physics} \begin{document} $\bra{\Psi}\ket{\Psi}$ $\expval{A}{\Psi}$ \end{document} It offers many other goodies for typsetting physics things. Details can be found in the manul ( texdoc physics from command prompt/terminal). Use \braket{0|0} : \documentclass{standalone} \usepackage{braket} \begin{document} $\braket{0|0}$ \end{document} A solution using the mathtools package: \documentclass{article} \usepackage{mathtools} \DeclarePairedDelimiter\bra{\langle}{\rvert} \DeclarePairedDelimiter\ket{\lvert}{\rangle} \DeclarePairedDelimiterX\braket[2]{\langle}{\rangle}{#1 \delimsize\vert #2} \begin{document} \begin{align*} \bra{a} &= \bra*{\frac{a}{1}} \\ \ket{a} &= \ket*{\frac{a}{1}} \\ \braket{a}{b} &= \braket*{\frac{a}{1}}{\frac{b}{1}} \end{align*} \end{document} Notice that the starred versions of the macros scale automatically.

Cnpj Generator Code Example

Example: cnpj generator alguns ai: 87.736.276/0001-10 57.768.821/0001-90 84.577.905/0001-19 57.556.282/0001-25 12.872.344/0001-70

Android Context.getResources.updateConfiguration() Deprecated

Answer : Inspired by Calligraphy, I ended up creating a context wrapper. In my case, I need to overwrite system language to provide my app users with the option of changing app language but this can be customized with any logic that you need to implement. import android.annotation.TargetApi; import android.content.Context; import android.content.ContextWrapper; import android.content.res.Configuration; import android.os.Build; import java.util.Locale; public class MyContextWrapper extends ContextWrapper { public MyContextWrapper(Context base) { super(base); } @SuppressWarnings("deprecation") public static ContextWrapper wrap(Context context, String language) { Configuration config = context.getResources().getConfiguration(); Locale sysLocale = null; if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N) { sysLocale = getSystemLocale(config); } else { sysL