Skip to main content

Posts

React(under construction)

  src/App.js   import React, { Component } from 'react'; import './App.css'; class App extends Component { render() { const helloWorld = 'Welcome to the Road to learn React'; return ( <div className="App"> <h2>{helloWorld}</h2> </div> ); } } export default App;   Better development -------------------------------------- Hot Module Replacement In create-react-app it is already an advantage that the browser automatically refreshes the page when you change your source code. Try it by changing the helloWorld variable in your src/App.js file. The browser should refresh the page. But there is a better way of doing it. Hot Module Replacement (HMR) is a tool to reload your application in the browser. The browser doesn’t perform a page refresh. You can easily activate it in create-react-app. In your src/index.js, your entry point to React, you have to add one little configuration ------------------------------------------------ in index....

django ORM Shell

---- python manage.py shell $from django.contrib.auth.models import User $from blog.models import Post $user = User.objects.get(username='admin') $Post.objects.create(      title='One more post',       slug='one-more-post',       body='Post body.',       author=user ) >>> post.save()  Updating objects $post.title = 'New title'  >>> post.save()  Using the filter() method $Post.objects.filter(publish__year=2015) Post.objects.filter(publish__year=2015)\ .exclude(title__startswith='Why') Post.objects.order_by('title') Deleting objects post = Post.objects.get(id=1) post.delete()    

Admin.py(django)

 from django.contrib import admin from .models import Post # Register your models here. class PostAdmin(admin.ModelAdmin):     list_display = ('title','slug','author','publish','status')     list_filter =('status','created','publish','author')     search_fields = ('title','body')     prepopulated_fields = {'slug': ('title',)}     raw_id_fields = ('author',)     date_hierarchy = 'publish'     ordering = ['status', 'publish'] admin.site.register(Post,PostAdmin)

data visualize(bar chart)

from matplotlib import pyplot as plt movies = ["Annie Hall", "Ben-Hur", "Casablanca", "Gandhi", "West Side Story"] num_oscars = [5, 11, 3, 8, 10] #bar chart # bars are by default width 0.8, so we'll add 0.1 to the left coordinates # so that each bar is centered #xs = [i + 0.1 for i, _ in enumerate(movies)] # plot bars with left x-coordinates [xs], heights [num_oscars] plt.bar(movies,num_oscars,color='red') #label x-axis with movie names at bar centers #plt.xticks([i + 0.5 for i, _ in enumerate(movies)], movies) plt.show() fig:-

Data visualize with matplotlib(solid line)

Nominal GDP      from matplotlib import pyplot as plt      years = [1950, 1960, 1970, 1980, 1990, 2000, 2010]      gdp = [300.2, 543.3, 1075.9, 2862.5, 5979.6, 10289.7, 14958.3]      plt.title('GDP')      plt.ylabel('Billios of $')      plt.plot(years,gdp,color='red',marker='o',linestyle='solid')      plt.show() * plt.plot(x,y,color,marker per year,linestyle) there are several line style '-', '--', '-.', ':', 'None', ' ', '', 'solid', 'dashed', 'dashdot', 'dotted' fig-

Node js

Start -------------------------------- npm init Install dependency ---------------------------------- npm install uuid Install dev dependency ---------------------------------------- npm install -D nodemon