Skip to content

Instantly share code, notes, and snippets.

Voon Ming Hann eldyvoon

  • Malaysia
Block or report user

Report or block eldyvoon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@eldyvoon
eldyvoon / js
Created Jun 29, 2019
Users.split.spec.js
View js
import React from "react";
import { render, waitForElement } from "@testing-library/react";
import "jest-dom/extend-expect";
import axios from "axios";
import Users, { url } from "./Users";
afterEach(() => {
axios.get.mockClear();
});
@eldyvoon
eldyvoon / js
Created Jun 29, 2019
Users.spec.js
View js
import React from "react";
import { render, waitForElement } from "@testing-library/react";
import "jest-dom/extend-expect";
import axios from "axios";
import Users, { url } from "./Users";
test("show loader when it's fetching data, then render users' name on rows", async () => {
axios.get.mockResolvedValueOnce({
data: {
results: [
@eldyvoon
eldyvoon / js
Created Jun 29, 2019
jest.config.js
View js
module.exports = {
setupFilesAfterEnv: ["@testing-library/react/cleanup-after-each"]
};
View js
export default {
get: jest.fn().mockResolvedValue({ data: {} })
};
View js
import React, { useState, useEffect } from "react";
import axios from "axios";
import styled from "styled-components";
const Loader = styled.div``;
const Row = styled.li`
list-style: none;
margin: 10px;
`;
@eldyvoon
eldyvoon / gist:87213c12a788feb8a3484ebf03311418
Created Sep 16, 2018
media query mixin scss/sass to avoid duplication
View gist:87213c12a788feb8a3484ebf03311418
// variables.scss file
$breakpoints:(
sm: 640px,
md: 1200px,
lg: 1400px,
xl: 1900px
);
// mixins.scss file
View gist:ca80812e2f0074c605ea0e7ef7b83b13
const moment = require('moment')
const crypto = require('crypto')
exports.sign = (req, res) => {
const s3Config = {
bucket: 'assets.example.com',
region: 's3-ap-southeast-1',
keyStart: 'uploads/',
params: {
acl: 'public-read',
@eldyvoon
eldyvoon / gist:179b70809ea644ce5269a02c833e200b
Created Jan 25, 2018
react-modal css scoping parentSelector
View gist:179b70809ea644ce5269a02c833e200b
//util
export default getClassesFromNode = node => {
const classnames = node && node.className
let classnames_in_string = ''
classnames.split(' ').forEach(v=>{
classnames_in_string += '.' + v
})
return ()=>document.querySelector(classnames_in_string)
}
@eldyvoon
eldyvoon / matrix_spiral.js
Created Jan 5, 2018
Matrix Spiral in JavaScript
View matrix_spiral.js
//specs
matrix(2)
[[1,2],
[4,3]]
matrix(4)
[[1,2,3,4],
[12,13,14,5],
[11,16,15,6],
[10,9,8,7]]
@eldyvoon
eldyvoon / vowels.js
Created Jan 5, 2018
Find vowels in JavaScript
View vowels.js
//specs
vowels('Hello World!') //3
vowels('My name is javascript') //6
//solution 1
function vowels(str) {
const vowelChar = ['a', 'e', 'i', 'o', 'u'];
let count = 0;
for (let char of str.toLowerCase()) {
You can’t perform that action at this time.