Skip to content

Instantly share code, notes, and snippets.

@elado
elado / README.md
Last active April 9, 2024 03:19
American Express - Add all offers to card at once (bookmarklet)

American Express - Add all offers to card at once

If you own an AMEX card, you can add a bunch of offers to the card in this link: https://global.americanexpress.com/offers/eligible

There are many offers, and they change all the time. Instead of clicking "Add to card" repeatedly, I created this bookmarklet.

In Chrome, add a new bookmark (right click on bookmarks bar -> "Add Page...") with the following URL:

@mrk-han
mrk-han / emulator-install-using-avdmanager.md
Last active May 1, 2024 21:12
Installing and creating Emulators with AVDMANAGER (For Continuous Integration Server or Local Use)

Install and Create Emulators using AVDMANAGER and SDKMANAGER

TL;DR

For an emulator that mimics a Pixel 5 Device with Google APIs and ARM architecture (for an M1/M2 Macbook):

  1. List All System Images Available for Download: sdkmanager --list | grep system-images

  2. Download Image: sdkmanager --install "system-images;android-30;google_atd;arm64-v8a"

import React from "react";
import { Location } from "@reach/router";
let scrollPositions = {};
class ManageScrollImpl extends React.Component {
componentDidMount() {
try {
// session storage will throw for a few reasons
// - user settings
@ohlookemus
ohlookemus / docker-compose.yml
Created January 29, 2018 18:26
Sample Docker Compose Traefik Config
version: '3'
services:
api:
container_name: api
restart: always
image: registry.example.com/example/example-api:prd
build: .
expose:
- "8000"
env_file: .env
@rafaelrozon
rafaelrozon / mock_axios_storybook.jsx
Last active April 26, 2023 12:29
Mock Axios requests in Storybook
import React from 'react';
import { storiesOf } from '@storybook/react';
// 1. import axios and MockAdapter
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
// 2. create the mock
const mock = new MockAdapter(axios);
@jaredpalmer
jaredpalmer / Formik-Autosave.jsx
Last active December 29, 2022 01:22
Formik-Autosave
import React from 'react';
import PropTypes from 'prop-types'
import debounce from 'lodash.debounce' // or whatevs
import isEqual from 'lodash.isEqual'
class AutoSave extends React.Component {
static contextTypes = {
formik: PropTypes.object
}
import React from 'react';
import { connect } from 'react-redux';
import { push, replace } from 'redux-router';
export function requireLoggedIn(Component) {
// a wrapper that requires a user be logged in. You can decide what 'logged in' means - in this example,
// a user is considered to be logged in if usersStore.meta.self !== null
class AuthComponent extends React.Component {
@jgillman
jgillman / restore.sh
Last active May 20, 2024 19:56
pg_restore a local db dump into Docker
# Assumes the database container is named 'db'
DOCKER_DB_NAME="$(docker-compose ps -q db)"
DB_HOSTNAME=db
DB_USER=postgres
LOCAL_DUMP_PATH="path/to/local.dump"
docker-compose up -d db
docker exec -i "${DOCKER_DB_NAME}" pg_restore -C --clean --no-acl --no-owner -U "${DB_USER}" -d "${DB_HOSTNAME}" < "${LOCAL_DUMP_PATH}"
docker-compose stop db
FROM python:2.7-alpine
MAINTAINER Nick Janetakis <nick.janetakis@gmail.com>
ENV INSTALL_PATH /bsawf
RUN mkdir -p $INSTALL_PATH
WORKDIR $INSTALL_PATH
COPY requirements.txt requirements.txt
RUN apk add --no-cache --virtual .build-deps \
from django import forms
from django.contrib.auth.models import User
class UserProfileForm(forms.ModelForm):
class Meta:
model = User
fields = ['first_name', 'last_name', 'email']