Skip to content

Instantly share code, notes, and snippets.

View devbkhadka's full-sized avatar

Dev devbkhadka

  • SmartMobe Solutions PVT. LTD.
  • Kathmandu, Nepal
View GitHub Profile
@devbkhadka
devbkhadka / service.md
Last active May 26, 2021 13:07 — forked from miromannino/service.md
Sample /etc/init.d script

Sample service script for debian/ubuntu

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name
.App {
display: flex;
flex-direction: column;
height: 100vh;
color: white;
overflow: hidden;
}
.App-header {
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)})
@devbkhadka
devbkhadka / Restaurants.test.js
Last active April 12, 2020 08:34
jest tutorial
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 April 12, 2020 08:03
Jest Tutorial
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 / restaurants.json
Last active April 12, 2020 06:38
jest tutorial
[
{
"id": 1,
"name": "MacDonald",
"location": [27.696927, 85.329353]
},
{
"id": 2,
"name": "Bajeko Sekuwa",
"location": [26.212754, 84.961525]
@devbkhadka
devbkhadka / App.test.js
Last active April 11, 2020 13:29
Jest Tutorial
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 November 10, 2019 02:16
Numpy Tutorial - Vectorization, Broadcasting, Fancy Indexing
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 November 10, 2019 02:14
Linear Regression Tutorial With Intution, Math and Code
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 September 16, 2019 16:29
provision ubuntu server to host django site using nginx and gunicorn
# 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