Skip to content

Instantly share code, notes, and snippets.

@JaosnHsieh
JaosnHsieh / enum-access.js
Created August 23, 2018 14:45 — forked from bnoguchi/enum-access.js
How to access enumValues in mongoose from a Model or Document
var mongoose = require('./index')
, TempSchema = new mongoose.Schema({
salutation: {type: String, enum: ['Mr.', 'Mrs.', 'Ms.']}
});
var Temp = mongoose.model('Temp', TempSchema);
console.log(Temp.schema.path('salutation').enumValues);
var temp = new Temp();
console.log(temp.schema.path('salutation').enumValues);
@JaosnHsieh
JaosnHsieh / axios-catch-error.js
Created September 10, 2018 08:58 — forked from fgilio/axios-catch-error.js
Catch request errors with Axios
axios.put(this.apiBaseEndpoint + '/' + id, input)
.then((response) => {
// Success
})
.catch((error) => {
// Error
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
// console.log(error.response.data);
@JaosnHsieh
JaosnHsieh / tableRenderingExample.js
Last active November 22, 2018 09:49 — forked from markerikson/tableRenderingExample.js
React expandable table rows example ( accordion table )
class ParentComponent extends Component {
constructor() {
super();
this.state = {
data : [
{id : 1, date : "2014-04-18", total : 121.0, status : "Shipped", name : "A", points: 5, percent : 50},
{id : 2, date : "2014-04-21", total : 121.0, status : "Not Shipped", name : "B", points: 10, percent: 60},
{id : 3, date : "2014-08-09", total : 121.0, status : "Not Shipped", name : "C", points: 15, percent: 70},
{id : 4, date : "2014-04-24", total : 121.0, status : "Shipped", name : "D", points: 20, percent : 80},
@JaosnHsieh
JaosnHsieh / InstallingTmuxOnCentOS.md
Created December 3, 2018 10:27 — forked from pierreprinetti/InstallingTmuxOnCentOS.md
Installing tmux 2.3 on CentOS 7

Installing tmux 2.3 on CentOS

Prerequites

  • libevent libevent-devel libevent-headers
  • curl
# remove old pkgs
@JaosnHsieh
JaosnHsieh / app.js
Created January 23, 2019 10:11 — forked from stongo/app.js
Joi validation in a Mongoose model
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
var db = mongoose.connection;
db.on('error', function() {
return console.error.bind(console, 'connection error: ');
});
@JaosnHsieh
JaosnHsieh / web-servers.md
Created February 22, 2019 06:22 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@JaosnHsieh
JaosnHsieh / graphql.ts
Created July 16, 2019 23:12 — forked from mfellner/graphql.ts
Using Apollo Server in Next.js 9 with API route in pages/api/graphql.ts
import { ApolloServer, gql } from 'apollo-server-micro';
const typeDefs = gql`
type Query {
sayHello: String
}
`;
const resolvers = {
Query: {
@JaosnHsieh
JaosnHsieh / .gitignore
Created April 28, 2020 10:04 — forked from iffy/.gitignore
Example using electron-updater with `generic` provider.
node_modules
dist/
yarn.lock
wwwroot
@JaosnHsieh
JaosnHsieh / .gitignore
Created April 28, 2020 10:04 — forked from iffy/.gitignore
Example using electron-updater with `generic` provider.
node_modules
dist/
yarn.lock
wwwroot
@JaosnHsieh
JaosnHsieh / MANUAL.md
Created August 3, 2020 09:02 — forked from kimyvgy/MANUAL.md
Deploy nodejs app with gitlab.com and pm2

Deploy nodejs app with gitlab.com and pm2

This manual is about setting up an automatic deploy workflow using nodejs, PM2, nginx and GitLab CI. It is tested on:

  • Target server: Ubuntu 16.04 x64. This is suitable for Ubuntu 14.x.
  • Windows 10 on my PC to work.