Skip to content

Instantly share code, notes, and snippets.

View stoneboyindc's full-sized avatar

Nick Chang stoneboyindc

View GitHub Profile
https://upbeat-handball.glitch.me/
https://glitch.com/edit/#!/upbeat-handball
https://glitch.com/edit/#!/leather-ethernet
@stoneboyindc
stoneboyindc / index.js
Created June 3, 2019 14:47
GetColorByDay()
const oneDay=1000*60*60*24;
const firstMondayDay = new Date("June 3, 2019");
const colors = ["Red", "Orange", "Yellow", "Green", "Blue", "Purple", "Black"];
function checkFirstMonday(day) {
if (day.getDay() != 1) {
throw "The first Monday is not set correctly.";
}
}
@stoneboyindc
stoneboyindc / gist:130e5cdb16739c53e93f9e5d479e1933
Created June 21, 2019 02:53
norman's bloccit test result
> bloccit@1.0.0 test /Users/nickchang/work/thinkful/tc/norman/bloccit
> export NODE_ENV=test&& jasmine
Started
server is listening for requests on port 3000
................................TypeError: Cannot read property 'title' of null
at Post.findOne.then (/Users/nickchang/work/thinkful/tc/norman/bloccit/spec/integration/posts_spec.js:270:26)
at tryCatcher (/Users/nickchang/work/thinkful/tc/norman/bloccit/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/nickchang/work/thinkful/tc/norman/bloccit/node_modules/bluebird/js/release/promise.js:517:31)
at Promise._settlePromise (/Users/nickchang/work/thinkful/tc/norman/bloccit/node_modules/bluebird/js/release/promise.js:574:18)
nickchang@Nicks-MacBook-Pro:~/work/thinkful/tc/donovanky/bloccit$ npm test
> bloccit@1.0.0 test /Users/nickchang/work/thinkful/tc/donovanky/bloccit
> set NODE_ENV=test&& jasmine
Started
server is listening for requests on port 3000
...sequelize deprecated Model.all has been deprecated, please use Model.findAll instead node_modules/sequelize/lib/model.js:4228:9
F.Internal Server Error. Redirecting to /topic/new
Fsequelize deprecated Model.findById has been deprecated, please use Model.findByPk instead node_modules/sequelize/lib/model.js:4208:9
@stoneboyindc
stoneboyindc / Cart.js
Created September 12, 2019 17:04
Revised Cart component
import React, { Component } from 'react';
import Total from './Total';
const USCurrencyFormat = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD'
});
class Cart extends Component {
function nbYear(p0, percent, aug, P) {
// your code
var numYears = 0;
var currentPop = p0;
var convertPercent;
if (percent === null || percent == 0) {
convertPercent = 0;
} else {
convertPercent = percent * .01;
Method 1: Using `bind()` method / Constructor bind
class Toggle extends React.Component {
constructor(props) {
super(props);
this.state = {isToggleOn: true};
// This binding is necessary to make `this` work in the callback
this.handleClick = this.handleClick.bind(this);
}
Watch Usage
› Press a to run all tests.
› Press f to run only failed tests.
› Press q to quit watch mode.
› Press p to filter by a filename regex pattern.
› Press t to filter by a test name regex pattern.
› Press Enter to trigger a test run.
PASS src/App.test.js
FAIL src/SearchBar/SearchBar.test.js
● SearchBar Component › triggers onChange event
import React, { Component } from 'react';
import SearchForm from './SearchForm/SearchForm';
import DisplayList from './DisplayList/DisplayList';
import './App.css';
const searchURL = 'https://www.googleapis.com/books/v1/volumes'
function formatQueryParams(params) {
const queryItems = Object.keys(params)
.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`)
const request = require("request");
const server = require("../../src/server");
const base = "http://localhost:3000/advertisements/";
describe("routes : advertisements", () => {
describe("GET /advertisements", () => {
it("should return a status code 200", done => {
request.get(base, (err, res, body) => {
expect(res.statusCode).toBe(200);
done();