Skip to content

Instantly share code, notes, and snippets.

View tkssharma's full-sized avatar
🎯
only JS

codewithtkssharma tkssharma

🎯
only JS
View GitHub Profile
const {promisify} = require('util');
const fs = require('fs');
const readFileAsync = promisify(fs.readFile);
readFileAsync(filePath, {encoding: 'utf8'})
.then((text) => {
console.log('CONTENT:', text);
})
.catch((err) => {
console.log('ERROR:', err);
});
fs.readdir(source, function (err, files) {
if (err) {
console.log('Error finding files: ' + err)
} else {
files.forEach(function (filename, fileIndex) {
console.log(filename)
gm(source + filename).size(function (err, values) {
if (err) {
}.bind(this))
}
{
// Use IntelliSense to learn about possible Node.js debug attributes.
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"runtimeExecutable":"node --inspect",
{
// Use IntelliSense to learn about possible Node.js debug attributes.
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Node: Nodemon",
"restart": true,
"protocol": "inspector",
FROM node:carbon
# Create app directory
WORKDIR /usr/src/app
# Bundle app source
COPY . /usr/src/app/
# npm install
RUN apt-get update && apt-get install && npm install
version: '3.5'
services:
mysql:
container_name: mysql_db
image: mysql:5.7
volumes:
- ~/datadir/mysql:/var/lib/mysql
ports:
- 3306:3306
- 33060:33060
// src/app/ping/ping.component.ts
import { HttpClient } from '@angular/common/http';
// ...
export class AppComponent {
constructor(public http: HttpClient) {}
public ping() {
this.http.get('https://example.com/api/things')
.subscribe(
data => console.log(data),
err => console.log(err)
import { Injectable } from '@angular/core'
import { HttpInterceptor, HttpHandler, HttpRequest, HttpEvent, HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/do';
@Injectable()
export class HeaderInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
const dummyrequest = req.clone({
return (
<div key={props.questionId} className="quiz-story">
<QuestionCount counter={props.counter} viewreults={props.viewreults}
counter={props.questionId}
total={props.questionTotal}
/>
<Question content={props.question} />
<ul className="answerOptions">
{props.answerOptions.map(renderAnswerOptions)}
</ul>
import React from 'react';
function Question(props) {
return (
<div>
<h2 className="question">{props.content}</h2>
</div>
);
}