Skip to content

Instantly share code, notes, and snippets.

View 4skinSkywalker's full-sized avatar
♥️
Stay strong guys!

Fred's GitHub 4skinSkywalker

♥️
Stay strong guys!
  • Italy
View GitHub Profile
@4skinSkywalker
4skinSkywalker / questionMarks.js
Created February 23, 2019 19:33
"...challenge where users struggled most to get a perfect score and spent the longest time solving.."
function questionsMarks(string) {
let number = pair = count = 0
for (let char of string) {
if ( !isNaN(char) ) {
if (number && number + +char === 10) {
@4skinSkywalker
4skinSkywalker / vowelSquare.js
Created February 23, 2019 19:46
The second hardest challenge listed in the “easy” section of Coderbyte.
function vowelSquare(matrix) {
let vowels = {
a: 1,
e: 1,
i: 1,
o: 1,
u: 1
}
@4skinSkywalker
4skinSkywalker / scaleBalancing.js
Created February 23, 2019 19:51
The third hardest challenge listed in the “easy” section of Coderbyte.
function scaleBalancing(plates, weights) {
weights.sort((a, b) => a - b)
let [a, b] = plates
if (a === b) {
return 'already balanced'
}
@4skinSkywalker
4skinSkywalker / correctPath.js
Last active February 24, 2019 01:27
The fourth hardest challenge listed in the “easy” section of Coderbyte.
function isValid(string) {
let v = 0
let h = 0
for (let char of string) {
if (char === 'd') v++
if (char === 'u') v--
if (char === 'r') h++
@4skinSkywalker
4skinSkywalker / closestEnemy.js
Created February 24, 2019 12:32
The fifth hardest challenge listed in the “easy” section of Coderbyte.
function closestEnemy(matrix) {
let length = matrix.length
let isValid = matrix.some(v => v.includes(2))
if (!isValid) return -1
let startingPoint
import { HttpClientModule } from '@angular/common/http'
import { HttpClientInMemoryWebApiModule } from 'angular-in-memory-web-api'
import { MyInMemoryService } from './services/my-in-memory.service'
@NgModule({
imports: [
HttpClientModule,
// import HttpClientInMemoryWebApiModule after HttpClientModule
HttpClientInMemoryWebApiModule.forRoot(MyInMemoryService)
]
import { InMemoryDbService } from 'angular-in-memory-web-api';
import { RequestInfo } from 'angular-in-memory-web-api/interfaces';
export class MyInMemoryService implements InMemoryDbService {
// In-Memory DB will intercept /api/whatever calls and return data
createDb() {
const customers = [
{ id: 1, username: 'fred92', password: '1234' },
{ id: 2, username: 'john69', password: 'abcd' },
@Injectable()
export class CustomersService {
constructor(
private http: Http) { }
getAll() {
return this.http.get('api/customers')
.subscribe(customers => {
console.log(customers)
import { InMemoryDbService } from 'angular-in-memory-web-api'
import { RequestInfo } from 'angular-in-memory-web-api/interfaces'
export class MyInMemoryService implements InMemoryDbService {
createDb() {
// same as before
}
// HTTP POST interceptor
import { Component, OnInit } from '@angular/core'
import { Router } from '@angular/router'
import { tap, catchError } from 'rxjs/operators'
import { throwError } from 'rxjs'
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css']
})