Skip to content

Instantly share code, notes, and snippets.

Dev devbkhadka

View GitHub Profile
View App.css
.App {
display: flex;
flex-direction: column;
height: 100vh;
color: white;
overflow: hidden;
}
.App-header {
View fetchRestaurants-utils.js
import {fetchRestaurants, RESTAURANTS_URL} from '../utils'
import * as fixtures from '../fixtures'
jest.spyOn(global, 'fetch')
describe('fetchRestaurants', ()=>{
beforeEach(()=>{
global.fetch.mockClear()
global.fetch.mockResolvedValue({text: ()=>JSON.stringify(fixtures.dummyRestaurants)})
View restaurants.json
[
{
"id": 1,
"name": "MacDonald",
"location": [27.696927, 85.329353]
},
{
"id": 2,
"name": "Bajeko Sekuwa",
"location": [26.212754, 84.961525]
View Restaurants.test.js
import React from 'react'
import {render, fireEvent} from '@testing-library/react'
import Restaurants from '../Restaurants'
import * as fixtures from '../fixtures'
import {calculateDistance} from '../utils'
jest.mock('../utils')
describe("Restaurants Component", ()=>{
it("should render restaurants passed to it", ()=>{
// render function returns a handle
@devbkhadka
devbkhadka / App.js
Last active Apr 12, 2020
Jest Tutorial
View App.js
import React, { useEffect, useState } from 'react';
import './App.css';
import { fetchRestaurants } from './utils';
import Restaurants from './Restaurants';
function App() {
const [restaurants, setRestaurants] = useState(null)
useEffect(()=>{
fetchRestaurants()
.then(setRestaurants)
@devbkhadka
devbkhadka / App.test.js
Last active Apr 11, 2020
Jest Tutorial
View App.test.js
import React from 'react';
import { render } from '@testing-library/react';
import App from '../App';
import Restaurants from '../Restaurants'
import {fetchRestaurants} from '../utils'
import * as fixtures from '../fixtures'
import { act } from 'react-dom/test-utils';
// First mock whole '../Restaurants' and '../utils'
// By default it will mock all the functions in module to return undefined
@devbkhadka
devbkhadka / numpy_tutorial.ipynb
Created Nov 10, 2019
Numpy Tutorial - Vectorization, Broadcasting, Fancy Indexing
View numpy_tutorial.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@devbkhadka
devbkhadka / linear_regression_tutorial.ipynb
Created Nov 10, 2019
Linear Regression Tutorial With Intution, Math and Code
View linear_regression_tutorial.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@devbkhadka
devbkhadka / commands.sh
Last active Sep 16, 2019
provision ubuntu server to host django site using nginx and gunicorn
View commands.sh
# this command is necessary to tell Systemd to load our new config file
elspeth@server:$ sudo systemctl daemon-reload
# this command tells Systemd to always load our service on boot
elspeth@server:$ sudo systemctl enable gunicorn-superlists-staging.ottg.eu
# this command actually starts our service
elspeth@server:$ sudo systemctl start gunicorn-superlists-staging.ottg.eu
# Check the Systemd logs for using
@devbkhadka
devbkhadka / saving_dnn_classifier.ipynb
Last active Aug 22, 2019
saving and restoring custom dnn classifier built using tensorflow for using it with RandomizedSearchCV
View saving_dnn_classifier.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
You can’t perform that action at this time.