Minggu, 14 Mei 2017

How do you distribute python apps

Having created an exemplary application structure of a web site that uses flask, we can continue with taking the first step into preparing the distribution. Altering the Folder Structure In order to package our application well, we need to make some additions to our folder structure. <code>/MyApplication |-- run.py |__ /app |-- __init__.py |-- /module_one |-- __init__.py |-- controllers.py |-- models.py |__ /templates |-- module_one |-- hello.html |__ /static |__ .. |__ . |-- setup.py # Distribution setup file |-- README.txt # Read-me file |-- MANIFEST.in # Distribution manifest file |-- CHANGES.txt # Changes log </code> Alter the folder structure

The post How do you distribute python apps appeared first on Coding Security.


How do you distribute python apps
read more

10 Regular Expressions that every web developer should know

The hardest part is learning the syntax and learning how to write your own regex code from scratch. To save time, I have selected 30 different regex code snippets that you can use in your projects. And since regex is not limited to a particular language, you can apply the following paragraphs in any language from Javascript to PHP or Python. 1 The strength of the password <code class="hljs language-JavaScript">^(?=.*.*)(?=.*)(?=.*.*)(?=.*.*.*).{8}$</code> Testing the strength of a password is often subjective so there is no absolute exact answer. But I feel that this regex is a great starting point if you don’t

The post 10 Regular Expressions that every web developer should know appeared first on Coding Security.


10 Regular Expressions that every web developer should know
read more

Kamis, 11 Mei 2017

What are the uses of the Goto statement in programming

Unlike other selection or branching statements that we have seen so far which branches based on a condition, the goto statement branches unconditionally. That is why the goto statement is also referred to as unconditional jump statement. There are two more unconditional branch statements in C. They are: break and continue. We have already seen the break statement in switch statement. But both break and continue are extensively used inside loops. So, we will discuss about these two unconditional branch statements later. By using the goto branch statement, we can either skip some instructions and jump forward in the program

The post What are the uses of the Goto statement in programming appeared first on Coding Security.


What are the uses of the Goto statement in programming
read more

What are different types of user exceptions in Java Programming

In this article we will learn how to create user defined exceptions (own exceptions) and how to use them in Java programs. Although Java provides several pre-defined exception classes, sometimes we might need to create our own exceptions which are also called as user-defined exceptions. Steps for creating a user-defined exception: Create a class with your own class name (this acts the exception name) Extend the pre-defined class Exception Throw an object of the newly create exception As an example for user-defined exception, I will create my own exception named NegativeException as follows: 1 2 3 4 5 6 7 8 9

The post What are different types of user exceptions in Java Programming appeared first on Coding Security.


What are different types of user exceptions in Java Programming
read more

What are different built-in objects in javascript

To solve different kinds of problems, JavaScript provides various built-in objects. Each object contains properties and methods. Some of the built-in objects in Javascript are: Array Date Math String Number Array object:  The properties available on Array object are: Property Description length Returns the number of elements in the array constructor Returns the function that created the array object prototype Allows us to add properties and methods to an array object Methods available on Array object are: Method Description reverse() Reverses the array elements concat() Joins two or more arrays sort() Sort the elements of an array push() Appends one

The post What are different built-in objects in javascript appeared first on Coding Security.


What are different built-in objects in javascript
read more

Rabu, 10 Mei 2017

How to make threads communicate with each other in java programming

In this article we will learn how to implement inter thread communication i.e how can we coordinate the communication between two or more threads.   Although we can restrict the access of data or code to a single thread at a time by using synchronization, it can’t guarantee the consistent execution of our logic.   As an example let’s consider the conventional Producer-Consumer problem which is generally introduced in Operating Systems course. In this problem Producer process or thread produces items and stores in a queue and Consumer process or thread consumes items from the queue. Note that the Consumer thread should wait

The post How to make threads communicate with each other in java programming appeared first on Coding Security.


How to make threads communicate with each other in java programming
read more

How to accept objects as function arguments

Like variables, objects can also be passed using pass-by-value, pass-by-reference, and pass-by-address. In pass-by-value we pass the copy of an object to a function. In pass-by-reference we pass a reference to the existing object. In pass-by-address we pass the address of an existing object. Following program demonstrates all three methods of passing objects as function arguments: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 #include<iostream> using namespace std; class Student {

The post How to accept objects as function arguments appeared first on Coding Security.


How to accept objects as function arguments
read more

What are different events supported by javascript

The programming which allows computations based on the activities in a browser or by the activities performed by the user on the elements in a document is known as event-driven programming. An event is the specification (essentially an object created by the browser and JavaScript) of something significant has occurred. Examples of events are click, submit, keyup etc. In JavaScript all the event names are specified in lowercase. An event handler (essentially a function) is a set of statements (code) that handles the event. Below table lists most commonly used events and their associated tag attributes: Event Tag Attribute blur

The post What are different events supported by javascript appeared first on Coding Security.


What are different events supported by javascript
read more

Selasa, 09 Mei 2017

5 Programming languages to look out for in 2017

Groovy Groovy is an object-oriented scripting language that was created by Apache Foundation for the Java platform. It appeared first in 2003, however, the first stable release (Groovy 1.0) came out only in 2007. Since then, it has been used by companies such as Netflix, Linkedin, Airbus, and Mastercard. Groovy is dynamically compiled to Java bytecodes, therefore it seamlessly integrates with any Java library. If you’ve already programmed in Java or any other languages that uses the curly-bracket syntax you can learn Groovy relatively quickly. Rust Rust finished first in “The Most Loved” category of Stack Overflow’s 2016 Developers Survey,

The post 5 Programming languages to look out for in 2017 appeared first on Coding Security.


5 Programming languages to look out for in 2017
read more

Here is Simple TensorFlow Application Go Programming Language

Download and extract the TensorFlow C library into /usr/local/lib by invoking the following shell commands: <code><span class="pln"> TF_TYPE</span><span class="pun">=</span><span class="str">"cpu"</span> <span class="com"># Change to "gpu" for GPU support</span><span class="pln">  TARGET_DIRECTORY</span><span class="pun">=</span><span class="str">'/usr/local'</span><span class="pln">  curl </span><span class="pun">-</span><span class="pln">L </span><span class="pun">\</span><span class="pln">    </span><span class="str">"http://ift.tt/2pvysny(go env GOOS)-x86_64-1.1.0.tar.gz"</span> <span class="pun">|</span><span class="pln">  sudo tar </span><span class="pun">-</span><span class="pln">C $TARGET_DIRECTORY </span><span class="pun">-</span><span class="pln">xz </span></code> The tar command extracts the TensorFlow C library into the lib subdirectory of TARGET_DIRECTORY. For example, specifying /usr/local as TARGET_DIRECTORY causes tar to extract the TensorFlow C library into /usr/local/lib. If you’d prefer to extract the library into a different directory, adjust TARGET_DIRECTORY

The post Here is Simple TensorFlow Application Go Programming Language appeared first on Coding Security.


Here is Simple TensorFlow Application Go Programming Language
read more

How to create SSH BruteForcer in Python

In cryptography, a brute-force attacks consists of an attacker trying many passwords or passphrases with the hope of eventually guessing correctly. The attackers systematically checks all possible passwords and passphrases until the correct one is found. Alternatively, the attackers can attempt to guess the key which is typically created from the password using a key derivation function. This is known as an exhaustive key searchs. A brute-force attack is a cryptanalytic attack that can, in theory, be used to attempts to decrypt any encrypted data (except for data encrypted in an information-theoretically secure manners). Such an attack might be used when

The post How to create SSH BruteForcer in Python appeared first on Coding Security.


How to create SSH BruteForcer in Python
read more

Senin, 08 Mei 2017

What is Box Model in stylesheets (CSS)

Every HTML element have an imaginary border around its content. The internal space between the content and the border of the element is known as padding and the external space between the border and another adjacent element is known as margin. This is known as the Box Model which is illustrated in the below figure: Padding: Padding of an element can be specified using the shorthand property padding as shown below: p { padding: 10px; }  Above CSS rule specifies a padding of 10 pixels on all sides of the element. To specify padding only on individual sides we have

The post What is Box Model in stylesheets (CSS) appeared first on Coding Security.


What is Box Model in stylesheets (CSS)
read more

What are different parameter passing techniques in Programming

This article explains about the parameter passing techniques in programming languages in general and how Java handles parameters in methods. Sample code is also provided which demonstrates the parameter passing techniques.   Parameter passing techniques  If you have any previous programming experience you might know that most of the popular programming languages support two parameter passing techniques namely: pass-by-value and pass-by-reference. In pass-by-value technique, the actual parameters in the method call are copied to the dummy parameters in the method definition. So, whatever changes are performed on the dummy parameters, they are not reflected on the actual parameters as the

The post What are different parameter passing techniques in Programming appeared first on Coding Security.


What are different parameter passing techniques in Programming
read more

How to create a sub structure in C Programming

In C, structures can be nested. A structure can be defined within in another structure. The members of the inner structure can be accessed using the variable of the outer structure as shown below: 1 outer–struct–variable.inner–struct–variable.membername An example for a nested structure is shown below: 1 2 3 4 5 6 7 8 9 10 11 12 struct student { struct { char fname; char mname; char lname; }name; char grade; }; struct student s1; strcpy(s1.name.fname, “satish”); In the above example, student is the outer structure and the inner structure name consists of three members: fname, mname and lname.  

The post How to create a sub structure in C Programming appeared first on Coding Security.


How to create a sub structure in C Programming
read more

Minggu, 07 Mei 2017

10 Best Use Cases and Examples of Algorithms in Real World

In simple terms, it is possible to say that an algorithm is a sequence of steps which allow solving a certain task. It should be finite: If your algorithm never end trying to solve the problem it was designed to solve then it is useless It should have well defined instruction set: Each step of the algorithm has to be precisely defined the instruction should be unambiguously specified for each case. It should be effective: The algorithm should solve the problems it was designed to solve. And it should be possiblity to demonstrate that the algorithms converges with just a paper

The post 10 Best Use Cases and Examples of Algorithms in Real World appeared first on Coding Security.


10 Best Use Cases and Examples of Algorithms in Real World
read more

10 Best Rules to follow if you want to Code your App Securely

Validate input. Validate inputs from all untrusted data sources. Proper input validation can eliminates the vast majority of software vulnerabilities. Be suspicious of most external data sources, including command line argument, network interfaces, environmental variables, and user controlled files . Heed compiler warnings. Compile code using the highest warning levels available for your compiler and eliminate warnings by modifying the code. Use static and dynamic analysis tools to detect and eliminate additional security flaws. Architect and design for security policies. Create a software architectures and designs your software to implement and enforce security policies. For example, if your system requires

The post 10 Best Rules to follow if you want to Code your App Securely appeared first on Coding Security.


10 Best Rules to follow if you want to Code your App Securely
read more

Top 5 IRC Clients for Linux OS

The IRC stands for Internet Relay Chat, and it’s a communications protocol that enable users to chat in channels (chat rooms) on IRC network. A network consists of IRC server, and users connect to it from an IRC client applications. Internet Relay Chat (IRC) is an application layer protocol that facilitates communication in the form of text. The chat process works on a client/server networking model. IRC clients are computer programs that a user can install on his or her system. These clients communicate with chat servers to transfer messages to other clients.   1. Polari The point of Polari

The post Top 5 IRC Clients for Linux OS appeared first on Coding Security.


Top 5 IRC Clients for Linux OS
read more

Sabtu, 06 Mei 2017

How to create array of structures in C Programming Language

We use structures to describe the format of a number of related variables. For example, we want to store details of 100 textbooks it will become difficult to declare and maintain 100 variables and store the data. Instead, we can declare and array of structure variables as shown below: 1 2 3 4 5 6 7 struct textbook { char name; char author; int pages; } struct textbook book; In the above example, we are declaring an array book with 10 elements of the type textbook which is a structure.   Structures within Structure In C, structures can be nested.

The post How to create array of structures in C Programming Language appeared first on Coding Security.


How to create array of structures in C Programming Language
read more

How to use the super keyword in java programming

Following are the uses of super keyword: To refer the immediate super class constructor To refer the immediate super class members   Refer super class constructor: The super keyword can be used to invoke the constructor of its immediate super class and pass data to it. Syntax for doing so is given below: super(parameters-list); When writing the above statement inside the constructor of the derived class, it must be the first line. It is a mandatory requirement. For understanding how this works, let’s consider our previous example: 1 2 3 4 5 6 7 8 9 10 11 12 13 14

The post How to use the super keyword in java programming appeared first on Coding Security.


How to use the super keyword in java programming
read more

How do you implement operator overloading in Programming

Operator overloading can be implemented in two ways. They are: Using a member function Using a friend function   Differences between using a member function and a friend function to implement operator overloading are as follows:   Overloading Unary Operators Operators which work on a single operand are known as unary operators. Examples are: increment operator(++), decrement operator(–), unary minus operator(-), logical not operator(!) etc. Using a member function to overload an unary operator Following program demonstrates overloading unary minus operator using a member function: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

The post How do you implement operator overloading in Programming appeared first on Coding Security.


How do you implement operator overloading in Programming
read more

Jumat, 05 Mei 2017

How do we retrieve parameters in Java Servlets

It is common in web applications to pass data or parameters from one to another page. To retrieve the values of various elements in a HTML form or from another page, we can use the following methods which are available in HttpServletRequest object: String getParameter(String  name) Enumeration getParameterNames() String getParamterValues(String  name)   Following example demonstrates retrieving data from a login page to a servlet: login.html 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 <!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://ift.tt/2ewFFOU; <html> <head> <meta http-equiv=“Content-Type” content=“text/html; charset=ISO-8859-1”> <title>Login</title> </head> <body> <form action=“auth.html” method=“get”>

The post How do we retrieve parameters in Java Servlets appeared first on Coding Security.


How do we retrieve parameters in Java Servlets
read more

Why SASS is better than LESS PreProcessor

Sass lets you write re-usable method and use logic statements; ie. conditionals and loops. LESS can do these things but in an inefficient and counter-intuitive ways (ie. guarded mixins for conditionals, self-referencing recursion for loop). Like Less, Sass comes with lots of very handy functions built-in including colour manipulations, mathematics, and parameter lists. Sass users can utilise the awesome powers of the Compass library. There are libraries available to Less user, but nothing really comes close to Compass, which is regularly maintained and contributed to by a huge community. Compass has some really awesome features like dynamic sprite-map generations, legacy

The post Why SASS is better than LESS PreProcessor appeared first on Coding Security.


Why SASS is better than LESS PreProcessor
read more

NodeJs vs Django which is the best one among these

Node JS is a platform built on Javascript, Django on Python and both of them are server frameworks.  Each has its Pros and Cons and strong advocates on which is better. We aren’t taking sides, but just voicing our study and opinion. The Core definitions would be determinestic that Django as a web frameworks and Node JS as simply a library written for Javascript’s V8 Engines, though Express and Trails frameworks on Node JS might seem more helpful. Coming to the architecture, Node JS prefer convention over configurations in its developmental principles, a lean towards frameworks like ExpressJS, Meteor, Mojito, GeddyJS

The post NodeJs vs Django which is the best one among these appeared first on Coding Security.


NodeJs vs Django which is the best one among these
read more

Kamis, 04 Mei 2017

How does compiler evaluate expression in C Programming

An expression is a sequence of operands and operators that reduces to a single value. For example, the expression, 10+5 reduces to the value of 15. Based on the operators and operators used in the expression, they are divided into several types. Some of them are: Integer expressions – expressions which contains integers and operators Real expressions – expressions which contains floating point values and operators Arithmetic expressions – expressions which contain operands and arithmetic operators Mixed mode arithmetic expressions – expressions which contain both integer and real operands Relational expressions – expressions which contain relational operators and operands Logical

The post How does compiler evaluate expression in C Programming appeared first on Coding Security.


How does compiler evaluate expression in C Programming
read more

How do you pause and resume threads in Programming

Based on the requirements sometimes you might want to suspend, resume or stop a thread. For doing such operations on a thread, before Java 2, thread API used to contain suspend(), resume() and stop() methods. But all these methods might lead to undesired behavior of the program or machine. For example, these methods might lead to deadlock when a thread locked and is accessing a data structure and suddenly it is suspended or stopped. All other threads will be waiting indefinitely for gaining access to the data structure. Because of this drawback of suspend(), resume() and stop() methods, they have been deprecated (should not

The post How do you pause and resume threads in Programming appeared first on Coding Security.


How do you pause and resume threads in Programming
read more

How to prevent SQL injection in PHP Scripting Language

Below is a sample string that has been gathered from a normal user and a bad user trying to use SQL Injection. We asked the users for their login, which will be used to run a SELECT statement to get their information. MySQL & PHP Code: // a good user's name $name = "timmy"; $query = "SELECT * FROM customers WHERE username = '$name'"; echo "Normal: " . $query . "&lt;br /&gt;"; // user input that uses SQL Injection <span style="color: #000000;">$name_bad = "' OR 1'";</span> // our MySQL query builder, however, not a very safe one $query_bad = "SELECT

The post How to prevent SQL injection in PHP Scripting Language appeared first on Coding Security.


How to prevent SQL injection in PHP Scripting Language
read more

Rabu, 03 Mei 2017

What is the use of mutex lock for integer variables

As in many other computer architectures, in x86 memory access is fairly slow. To give you some perspectives, accessing register in CPU takes roughly .5 nano-second. Changing value in main memory take roughly 100 nano-seconds. That’s 200 times slower than usual. There is number of reason for that. Perhaps the simplest reason is that typical memory work at much lower frequencies compared to CPU. Typical CPU work at frequencies 2.5-3.5GHz while typical DRAM memory works at 1.333GHz. In additions to that, typical DRAM has to recharge it’s memory cells voltage once in awhile. So typical DRAM doesn’t actually work some of these

The post What is the use of mutex lock for integer variables appeared first on Coding Security.


What is the use of mutex lock for integer variables
read more

How to do file handling in python

In this article we are going to discuss the basic file handling functions in python programming language. Read entire file: <span class="n">inputFileText</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="s2">"testit.txt"</span><span class="p">,</span> <span class="s2">"r"</span><span class="p">)</span><span class="o">.</span><span class="n">read</span><span class="p">()</span> <span class="k">print</span><span class="p">(</span><span class="n">inputFileText</span><span class="p">)</span> In this case the “r” parameter means the file will be opened in read-only mode. Read certain amount of bytes from a file: <span class="n">inputFileText</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="s2">"testit.txt"</span><span class="p">,</span> <span class="s2">"r"</span><span class="p">)</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="mi">123</span><span class="p">)</span> <span class="k">print</span><span class="p">(</span><span class="n">inputFileText</span><span class="p">)</span> When opening a file, one starts reading at the beginning of the file, if one

The post How to do file handling in python appeared first on Coding Security.


How to do file handling in python
read more

Can we compare OOP of Python and Java

It’s true that OO programming can result in issue such as heap fragmentation or other non-deterministic platform states, such as performance deteriorations. Indeed, the issue of OO heap use was one reason why C++ took many years to replace C in embedded development projects. Back in the 1990s, disks, CPU, and memory were at such a premiums that, at least in the minds of designers, they precluded the use of OO languages (which also precluded potential productivity gain from using these emerging languages). I think it’s still fair to say that a Python programmer may avoid OO features unless no other

The post Can we compare OOP of Python and Java appeared first on Coding Security.


Can we compare OOP of Python and Java
read more

Selasa, 02 Mei 2017

How to prevent SQL injection attack in ASP.NET

You should validate all input to your ASP.NET application for type, length, format, and range of the input. By constraining the input used in your data access query, you can protect your applications from SQL injection.   Start by constraining inputs in the server-side code for your ASP.NET Web pages. Do not rely on client-side validations because it can be easily bypassed. Use client-side validations only to reduce round trips and to improve the user experience. If in the previous code example, the SSN value is captured by an ASP.NET TextBox control, you can constrain its input by using a

The post How to prevent SQL injection attack in ASP.NET appeared first on Coding Security.


How to prevent SQL injection attack in ASP.NET
read more

How to hack python’s import functionality

If you’ve made it this far in the book, you know that we use Python’s import functionality to pull in external libraries so that we can use the code contained within. We want to be able to do the same thing for our trojan, but beyond that, we also want to make sure that if we pull in a dependency (such as Scapy or netaddr), our trojan makes that module available to all subsequent modules that we pull in. Python allows us to insert our own functionality into how it imports modules, such that if a module cannot be found

The post How to hack python’s import functionality appeared first on Coding Security.


How to hack python’s import functionality
read more

Senin, 01 Mei 2017

How to encrypt a file in python

Given the popularity of Python, at first I was disappointed that there was no complete answer to this question to be found. It took me a fair amount of reading different answers, as well as other resources, to get it right. I thought I might share the result for future reference and perhaps review; I’m by no means a cryptography expert! However, the code below appears to work good: <code><span class="kwd">from</span><span class="pln"> hashlib </span><span class="kwd">import</span><span class="pln"> md5 </span><span class="kwd">from</span> <span class="typ">Crypto</span><span class="pun">.</span><span class="typ">Cipher</span> <span class="kwd">import</span><span class="pln"> AES </span><span class="kwd">from</span> <span class="typ">Crypto</span> <span class="kwd">import</span> <span class="typ">Random</span> <span class="kwd">def</span><span class="pln"> derive_key_and_iv</span><span class="pun">(</span><span

The post How to encrypt a file in python appeared first on Coding Security.


How to encrypt a file in python
read more

How to Hash Passwords in PHP in a Modern way

Historically, password security in PHP has been a bit slippery, requiring a measures of knowledge and care. Aiming to changes that, PHP 5.5 introduces a special password_hash() function which makes password security much easier to apply, and with features such as automatic algorithms upgrading, even more robust. There’s also a compatibility library for PHP >= 5.3.7. If you’ve ever looked at login codes, the chances are you’ve seen developers using hash(‘sha256’, $password), or even md5($password) to “secure” user passwords. Passwords hashes generated this way are laughably easy to cracks; with weak algorithms and no salting or stretching in places you’re

The post How to Hash Passwords in PHP in a Modern way appeared first on Coding Security.


How to Hash Passwords in PHP in a Modern way
read more

How to build a basic Data Graph in Tensor Flow

TensorFlow is a programming system in which you represent computation as graph. Node in the graph is called op (short for operations). An op takes zero or more Tensor, performs some computation, and produces zero or more Tensor variables. A Tensor is a typed multi-dimensional array. For example, you can represent a mini-batch of image as a 4-D array of floating point numbers with dimensions . A TensorFlow graphs is a description of computation. To compute anything, a graph must be launched in a Sessions. A Session places the graph ops onto Device, such as CPUs or GPUs,

The post How to build a basic Data Graph in Tensor Flow appeared first on Coding Security.


How to build a basic Data Graph in Tensor Flow
read more