Netlify

Use case: ReactJS doesn’t render on some of the hosting platforms.

Netlify is a web hosting infrastructure and automation technology company based in San Francisco. Netlify works by connecting to your GitHub repository to pull your source code, then it typically runs a build process to pre-render all of your pages in static HTML.

The Git workflow for web development. Build, deploy, and manage modern web projects.

Create React App

Create React App without create-react-app : https://medium.com/@paul.allies/react-create-app-without-react-create-app-7c8341282645

First let’s create a folder for new project and install all dependencies
$> mkdir reactproject
$> cd reactproject
$> npm init
$> npm i -S react react-dom
$> npm i -D webpack webpack-cli webpack-dev-server
$> npm i -D babel babel-core babel-loader babel-preset-env babel-preset-react html-webpack-plugin http-server

mds and mds_stores constantly consuming cpu

The reason why your Spotlight is so active could be a number of things; it could be you have an app or multiple apps constantly changing some folder contents.

First let’s check whether Spotlight is the cause of the fans running so much. To test this, run the following in your terminal:

sudo mdutil -a -i off
this turns off indexing of files, and should result in a clear slow down of the fans if mds and/or mds_stores are to blame.

To turn indexing back on, run

sudo mdutil -a -i on
After this you could run the complete re-indexing of your hard drive (be aware this could be an over night job), it will delete your Spotlight data base forcing it to start over.

sudo rm -rf /.Spotlight-V100/*
The next and final step would be to add others to your (do not scan), privacy settings.

Ref:- https://apple.stackexchange.com/questions/144474/mds-and-mds-stores-constantly-consuming-cpu

Passing functions around Javascript

Passing functions around
You can, for example, do something like this:


function say(word) {
console.log(word);
}

function execute(someFunction, value) {
someFunction(value);
}

execute(say, “Hello”);
Read this carefully! We pass the function say as the first parameter to the execute function. Not the return value of say, but say itself!

Thus, say becomes the local variable someFunction within execute, and execute can call the function in this variable by issuing someFunction() (adding brackets).

Of course, because say takes one parameter, execute can pass such a parameter when calling someFunction.

We can, as we just did, pass a function as a parameter to another function by its name. But we don’t have to take this indirection of first defining, then passing it – we can define and pass a function as a parameter to another function in-place:


function execute(someFunction, value) {
someFunction(value);
}

execute(function(word){ console.log(word) }, “Hello”);
We define the function we want to pass to execute right there at the place where execute expects its first parameter.

This way, we don’t even need to give the function a name, which is why this is called an anonymous function.

This is a first glimpse at what I like to call “advanced” JavaScript, but let’s take it step by step. For now, let’s just accept that in JavaScript, we can pass a function as a parameter when calling another function. We can do this by assigning our function to a variable, which we then pass, or by defining the function to pass in-place.

Python Django Configuration Mac Terminal

After installing Python3

On Terminal ($) to check the version of python which is installed


$ Python -V
$ Python3 - V

To install pip


$ sudo easy_install pip

To install virtualenv try the code below


$ pip install virtualenv
# If the command returns permission error - try installing only for the #particular user -
pip install virtualenv --user

Setup virtual environment


python -m virtualenv venv

To activate virtual enviroment


source venv/bin.activate

Within the environment, install the Django package using pip. Installing Django allows us to create and run Django applications.

pip install Django

To check Django version after installation


django-admin --version

Django-admin is the command will allow to use all sort of things on Django


Django-admin

To create a Django project on the same directory use the command below. Note the ‘.’ too specify that to create the start project on the directory that we are in.


django-admin startproject trydjando .

To start the development server (which will start a development server at http://127.0.0.1:8000/


Python manage.py runserver

To kill the development server incase default port 8000 error

sudo fuser -k 8000/tcp. This should kill all the processes associated with port 8000.

For osx users you can use sudo lsof -t -i tcp:8000 | xargs kill -9

To link to database DATABASES on the settings.py file

Python manage.py migrate

To create a admin for the server (ex. default web portal http://127.0.0.1:8000/admin)


python manage.py createsuperuser

To change the password for the admin

python manage.py changepassword

DB Issues Finder

Provides information about current users, sessions, and processes-Ex: SPID , Status (sleeping, Background), Login (Domain\User1)
*************************************************************************
sp_who2

Shows you the last query that a spid ran
****************************************
DBCC InputBuffer

Fetch all the modified tables
*****************************
SELECT name, create_date, modify_date FROM sys.objects WHERE type = ‘P’ ORDER BY modify_date desc

Recently manipulated objects
****************************

SELECT TE.name ,
v.subclass_name ,
DB_NAME(t.DatabaseId) AS DBName ,
T.NTDomainName ,
t.NTUserName ,
t.HostName ,
t.ApplicationName ,
t.LoginName ,
t.Duration ,
t.StartTime ,
t.ObjectName ,
CASE t.ObjectType
WHEN 8259 THEN ‘Check Constraint’
WHEN 8260 THEN ‘Default (constraint or standalone)’
WHEN 8262 THEN ‘Foreign-key Constraint’
WHEN 8272 THEN ‘Stored Procedure’
WHEN 8274 THEN ‘Rule’
WHEN 8275 THEN ‘System Table’
WHEN 8276 THEN ‘Trigger on Server’
WHEN 8277 THEN ‘(User-defined) Table’
WHEN 8278 THEN ‘View’
WHEN 8280 THEN ‘Extended Stored Procedure’
WHEN 16724 THEN ‘CLR Trigger’
WHEN 16964 THEN ‘Database’
WHEN 16975 THEN ‘Object’
WHEN 17222 THEN ‘FullText Catalog’
WHEN 17232 THEN ‘CLR Stored Procedure’
WHEN 17235 THEN ‘Schema’
WHEN 17475 THEN ‘Credential’
WHEN 17491 THEN ‘DDL Event’
WHEN 17741 THEN ‘Management Event’
WHEN 17747 THEN ‘Security Event’
WHEN 17749 THEN ‘User Event’
WHEN 17985 THEN ‘CLR Aggregate Function’
WHEN 17993 THEN ‘Inline Table-valued SQL Function’
WHEN 18000 THEN ‘Partition Function’
WHEN 18002 THEN ‘Replication Filter Procedure’
WHEN 18004 THEN ‘Table-valued SQL Function’
WHEN 18259 THEN ‘Server Role’
WHEN 18263 THEN ‘Microsoft Windows Group’
WHEN 19265 THEN ‘Asymmetric Key’
WHEN 19277 THEN ‘Master Key’
WHEN 19280 THEN ‘Primary Key’
WHEN 19283 THEN ‘ObfusKey’
WHEN 19521 THEN ‘Asymmetric Key Login’
WHEN 19523 THEN ‘Certificate Login’
WHEN 19538 THEN ‘Role’
WHEN 19539 THEN ‘SQL Login’
WHEN 19543 THEN ‘Windows Login’
WHEN 20034 THEN ‘Remote Service Binding’
WHEN 20036 THEN ‘Event Notification on Database’
WHEN 20037 THEN ‘Event Notification’
WHEN 20038 THEN ‘Scalar SQL Function’
WHEN 20047 THEN ‘Event Notification on Object’
WHEN 20051 THEN ‘Synonym’
WHEN 20549 THEN ‘End Point’
WHEN 20801 THEN ‘Adhoc Queries which may be cached’
WHEN 20816 THEN ‘Prepared Queries which may be cached’
WHEN 20819 THEN ‘Service Broker Service Queue’
WHEN 20821 THEN ‘Unique Constraint’
WHEN 21057 THEN ‘Application Role’
WHEN 21059 THEN ‘Certificate’
WHEN 21075 THEN ‘Server’
WHEN 21076 THEN ‘Transact-SQL Trigger’
WHEN 21313 THEN ‘Assembly’
WHEN 21318 THEN ‘CLR Scalar Function’
WHEN 21321 THEN ‘Inline scalar SQL Function’
WHEN 21328 THEN ‘Partition Scheme’
WHEN 21333 THEN ‘User’
WHEN 21571 THEN ‘Service Broker Service Contract’
WHEN 21572 THEN ‘Trigger on Database’
WHEN 21574 THEN ‘CLR Table-valued Function’
WHEN 21577
THEN ‘Internal Table (For example, XML Node Table, Queue Table.)’
WHEN 21581 THEN ‘Service Broker Message Type’
WHEN 21586 THEN ‘Service Broker Route’
WHEN 21587 THEN ‘Statistics’
WHEN 21825 THEN ‘User’
WHEN 21827 THEN ‘User’
WHEN 21831 THEN ‘User’
WHEN 21843 THEN ‘User’
WHEN 21847 THEN ‘User’
WHEN 22099 THEN ‘Service Broker Service’
WHEN 22601 THEN ‘Index’
WHEN 22604 THEN ‘Certificate Login’
WHEN 22611 THEN ‘XMLSchema’
WHEN 22868 THEN ‘Type’
ELSE ‘Hmmm???’
END AS ObjectType
FROM [fn_trace_gettable](CONVERT(VARCHAR(150), ( SELECT TOP 1
value
FROM [fn_trace_getinfo](NULL)
WHERE [property] = 2
)), DEFAULT) T
JOIN sys.trace_events TE ON T.EventClass = TE.trace_event_id
JOIN sys.trace_subclass_values v ON v.trace_event_id = TE.trace_event_id
AND v.subclass_value = t.EventSubClass
WHERE TE.name IN ( ‘Object:Created’, ‘Object:Deleted’, ‘Object:Altered’ )
— filter statistics created by SQL server
AND t.ObjectType NOT IN ( 21587 )
— filter tempdb objects
AND DatabaseID 2
— get only events in the past 24 hours
AND StartTime > DATEADD(HH, -24, GETDATE())
ORDERBY t.StartTime DESC ;