Skip to content

Instantly share code, notes, and snippets.

View abnersajr's full-sized avatar

Abner Soares Alves Junior abnersajr

View GitHub Profile
@abnersajr
abnersajr / styles.js
Created December 18, 2022 23:55
better-ui-ahmadawais-course
const wrap = document.querySelector("body > div.aa_toc_wrap > div.aa_toc");
const HEIGHT = 560;
Object.assign(wrap.style, {
height: `${HEIGHT}px`,
maxHeight: `${HEIGHT}px`,
display: "block",
overflowY: "scroll",
padding: "0 20px",
});
WITH ranks AS (
SELECT
menu_category,
menu_items,
energy_kcal,
row_number() OVER (
PARTITION BY menu_category
ORDER BY
energy_kcal DESC
) as energy_kcal_rank
@abnersajr
abnersajr / batch-password-cpanel.js
Last active December 19, 2022 15:34
batch-password-change
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
const get_emails = Array.from(
document.querySelectorAll("[id^='account-name_']")
).map((item) => item.innerText);
const process_buttons = (emails) => {
const email = emails.pop();
document
@abnersajr
abnersajr / .mocharc.js
Last active December 19, 2022 15:33
useLayoutEffect Issue
const { loadOptions } = require("mocha/lib/cli/options");
const options = loadOptions(process.argv.slice(2));
let spec = "tests/**/*.js";
if (options._.length) {
spec = options._;
}
const common_config = {
require: ["./ts-node", "config/init-config.js", "tests/test-globals.js"],
@abnersajr
abnersajr / setup_macos.md
Last active December 1, 2020 14:47
Basic steps to setup my MacOS
@abnersajr
abnersajr / README.md
Last active March 26, 2020 14:04
Fixing issues with Xcode not selected. Usually saw on node-gyp installation

Fixing node-gyp

Install full Xcode

Open Xcode and the CLT will install

Then run sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

This uses the full Xcode CLT and node-gyp works.

@abnersajr
abnersajr / Components.jsx
Last active March 20, 2019 18:51
Components
// Without Mapper
const UserName = ({name}) => (
<p>{name}</p>
)
const UserBio = ({firstName, lastName, birthDate}) => ( //...
<p>{firstName} {lastName} - {birthDate}</p>
)
@abnersajr
abnersajr / goodWay.jsx
Last active March 21, 2019 17:18
Mapper the good way
// Your API Response or another data source
const API_RESPONSE = {
userName: "Talysson",
userLastName: "Cassiano",
birth: "01/04/1992",
evaluation: {
average: 4.5,
total: 20,
}
}
@abnersajr
abnersajr / badWay.jsx
Last active March 21, 2019 18:07
Mappers
// Not the best way to write components and tests, having different names for same data
const UserProfile = ({ name, lastName, birthDate, userEvaluation }) => {
const fullName = `${name} ${lastName}`
...
}
describe('UserProfile', () => {
it('renders with correct props', () => {
const MOCK_USER = {
name: 'Abner',
constructor() {
this.openModal = this.openModal.bind(this);
this.closeModal = this.closeModal.bind(this);
}
openModal(modal) {
this.setState({
[modal]: true,
});
}