Skip to content

Instantly share code, notes, and snippets.

View adamchenwei's full-sized avatar
🎯
Focusing

Adam Chen Wei adamchenwei

🎯
Focusing
View GitHub Profile
@mansueli
mansueli / testing_rls_supabase.mdx
Last active June 26, 2024 17:08
Testing Row Level Security (RLS) policies @supabase

Testing RLS policies

To test policies on the database itself (i.e., from the SQL Editor or from psql) without switching to your frontend and logging in as different users, you can utilize the following helper SQL procedures (credits):

grant anon, authenticated to postgres;

create or replace procedure auth.login_as_user (user_email text)
    language plpgsql
    as $$
@peckjon
peckjon / ClearDroplist.js
Last active January 26, 2024 20:41
Clear Honey Droplist
// paste into browser console at https://www.joinhoney.com/droplist to remove ALL Droplisted items
var script = document.createElement('script');
script.src = "https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(script);
setTimeout(() => {
$('img[alt="Remove this item from your Droplist"]').each(function(){this.click()});
$('button[aria-label="Remove item"]').each(function(){this.click()});
$('div[id="HoneyDropList:index-moreButton"]').click();
}, 2000);
@paolocarrasco
paolocarrasco / README.md
Last active July 4, 2024 19:00
How to understand the `gpg failed to sign the data` problem in git

Problem

You have installed GPG, then tried to commit and suddenly you see this error message after it:

error: gpg failed to sign the data
fatal: failed to write commit object

Debug

@emmiep
emmiep / puppeteer-demo1.js
Created March 3, 2018 15:29
Use puppeteer to get coordinates of an element
const Puppeteer = require('puppeteer');
(async () => {
const browser = await Puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
const header = await page.$('h1');
const rect = await page.evaluate((header) => {
const {top, left, bottom, right} = header.getBoundingClientRect();
@bjunc
bjunc / graphql-axios.js
Last active January 12, 2024 05:34
application/graphql vs application/json using axios
let input = { first_name: 'Foo', last_name: 'Bar' };
// application/graphql example
/* eslint-disable no-unused-vars */
let configGraphQL = {
url: '/graphql',
method: 'post',
headers: { 'Content-Type': 'application/graphql' },
data: `mutation { user(id: 1, input: ${ JSON.stringify(input) }){ full_name } }`
};
@marc-rutkowski
marc-rutkowski / README.md
Last active June 17, 2021 13:17
react-storybook with react-boilerplate (content of the .storybook/ directory)

react-storybook with react-boilerplate

Explains how to install and configure react-storybook into a project created from the react-boilerplate setup.

Intro

React-boilerplate (rbp) is a good starting point to create React apps, with a focus on performance, best practices and DX.

The community around the repository is amazing and a constant source of learning.

@adamchenwei
adamchenwei / karma.conf.js
Created October 26, 2016 15:21
ES6 + Babel + Browserify + Mocha + Chai + Karma + Istanbul + PhantomJS
var istanbul = require('browserify-istanbul');
module.exports = function (config) {
config.set({
basePath: '../',
files: ['src/scripts/**/*.js', 'test/unit/**/*.js'],
frameworks: ['browserify', 'mocha', 'chai'],
browsers: ['PhantomJS'], // 'Chrome'
@mxstbr
mxstbr / webpack-for-node-modules.js
Last active February 13, 2021 20:28
How to use webpack to compile node modules
/* eslint-disable no-var */
var path = require('path');
var autoprefixer = require('autoprefixer');
const MATCH_ALL_NON_RELATIVE_IMPORTS = /^\w.*$/i;
module.exports = [{
output: {
filename: '[name].js',
library: 'atrium-react-plugin-beta',
@subfuzion
subfuzion / curl.md
Last active July 3, 2024 11:43
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@dgraham
dgraham / copy-to-clipboard.js
Last active March 21, 2019 02:17
Copy attribute value, form input, or element text to the clipboard.
(function() {
function createNode(text) {
var node = document.createElement('pre');
node.style.width = '1px';
node.style.height = '1px';
node.style.position = 'fixed';
node.style.top = '5px';
node.textContent = text;
return node;
}