Skip to content

Instantly share code, notes, and snippets.

View EthanLiu1230's full-sized avatar
😜
I may be slow to respond.

Ethan Liu EthanLiu1230

😜
I may be slow to respond.
View GitHub Profile
@EthanLiu1230
EthanLiu1230 / rspec_model_testing_template.rb
Created April 27, 2021 04:14 — forked from PWSdelta/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@EthanLiu1230
EthanLiu1230 / admin-bro.ts
Created April 22, 2021 21:22
config admin-bro + feathers JS + Sequelize
import { Application } from './declarations';
import AdminBro from 'admin-bro';
import AdminBroExpress from '@admin-bro/express';
import AdminBroSequelize from '@admin-bro/sequelize';
import logger from './logger';
AdminBro.registerAdapter(AdminBroSequelize);
/**
* Usage:
*
@EthanLiu1230
EthanLiu1230 / admin.tsx
Created April 22, 2021 11:11
pages/admin.tsx nextJS dynamic render Component as a SPA
import dynamic from "next/dynamic";
import React from "react";
const ReactAdmin = dynamic(() => import("../admin/ReactAdmin"), {
ssr: false,
});
export default function admin() {
return <ReactAdmin />;
}
@EthanLiu1230
EthanLiu1230 / data.provider.ts
Created April 22, 2021 11:09
feathersJS client + React Admin
import {
CreateParams,
CreateResult,
DataProvider,
DeleteManyParams,
DeleteManyResult,
DeleteParams,
DeleteResult,
GetListParams,
GetListResult,
from django.shortcuts import render
from operator import attrgetter
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
from blog.views import get_blog_queryset
from blog.models import BlogPost
BLOG_POSTS_PER_PAGE = 10
@EthanLiu1230
EthanLiu1230 / ssh.md
Created January 15, 2020 17:46 — forked from bradtraversy/ssh.md
SSH & DevOps Crash Course Snippets

SSH Cheat Sheet

This sheet goes along with this SSH YouTube tutorial

Login via SSH with password (LOCAL SERVER)

$ ssh brad@192.168.1.29

Create folder, file, install Apache (Just messing around)

$ mkdir test

$ cd test

Mac app need to trash

macOS Mojave Gatekeeper

The most common messages received from users on Appked are re ports that the “app” is damaged and can’t be opened. You should move it to the Trash! Like this:

https://i0.wp.com/img.magimg.com/uploads/gatekeeper.jpg?zoom=2&w=620&ssl=1

It a simple fix and here is how we fix it:

Open the Terminal app from the /Applications/Utilities/ folder and then enter the following command syntax:

@EthanLiu1230
EthanLiu1230 / construct binary tree from inorder and postorder.java
Created January 15, 2020 17:04
Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. For example, given inorder = [9,3,15,20,7] postorder = [9,15,7,20,3] Return the following binary tree: 3 / \ 9 20 / \ 15 7
class Solution {
public TreeNode buildTree(int[] inorder, int[] postorder) {
return buildTree(inorder, inorder.length-1, 0, postorder, postorder.length-1);
}
private TreeNode buildTree(int[] inorder, int inStart, int inEnd, int[] postorder,
int postStart) {
// inStart to inEnd index backward
if (postStart < 0 || inStart < inEnd)
public class WeightedQuickUnionUF {
private int[] id; // parent link (site indexed)
private int[] sz; // size of component for roots (site indexed)
private int count; // number of components
public WeightedQuickUnionUF(int N) {
count = N;
id = new int[N];
for(int i = 0; i < N; i++) id[i] = i;
new Vue({
render: h => h(App)
}).$mount('#app');
/* equal to */
new Vue({
render: h => h(App),
el: '#app'
});