Skip to content

Instantly share code, notes, and snippets.

@tomleo
tomleo / README.md
Created January 17, 2023 20:01
Email Login w/ Django

Login Users with Email

A response to: Django: How to Log Users In With Their Email

There's an easier way than creating a custom user type. All you need to change is the AUTHENTICATION_BACKENDS setting!

See the example account app files in this gist!

Thanks!

const minute = 60;
const hour = minute * 60;
const day = hour * 24;
const week = day * 7;
const month = day * 30;
const year = day * 365;
/**
* Convert a date to a relative time string, such as
* "a minute ago", "in 2 hours", "yesterday", "3 months ago", etc.
@forsbergplustwo
forsbergplustwo / graphql_response_rubyfier.rb
Last active August 24, 2021 05:57
Proof of concept! Transforms Shopify GraphQL API responses to remove the need to type "edges" and "node", while also adding support for Ruby dot notation. We could also transform createAt to created_at.. but I think that will be "too much magic", as it won't match docs etc.
require 'json'
class GraphqlResponseRubyfier
def initialize(response)
@response = JSON.parse(response)
end
def rubyfy
rubyfied_response = to_o(@response)
puts(rubyfied_response)
// create a bookmark and use this code as the URL, you can now toggle the css on/off
// thanks+credit: https://dev.to/gajus/my-favorite-css-hack-32g3
javascript: (function() {
var elements = document.body.getElementsByTagName('*');
var items = [];
for (var i = 0; i < elements.length; i++) {
if (elements[i].innerHTML.indexOf('* { background:#000!important;color:#0f0!important;outline:solid #f00 1px!important; background-color: rgba(255,0,0,.2) !important; }') != -1) {
items.push(elements[i]);
}
}
@stolinski
stolinski / providerCompose.js
Created April 23, 2019 17:40
ProviderComposer
function ProviderComposer({ contexts, children }) {
return contexts.reduceRight(
(kids, parent) =>
React.cloneElement(parent, {
children: kids,
}),
children
);
}
@stidges
stidges / tailwind.itermcolors
Last active November 30, 2023 21:00
An iTerm2 color scheme based on the Tailwind CSS color scheme (https://tailwindcss.com/docs/colors)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.17254902422428131</real>
@wowkin2
wowkin2 / Readme.md
Last active March 22, 2024 02:22
Solution: "Exceeded 4 calls per second for api client" Python Shopify API - shopify_python_api

Solution for API call limit "shopify_python_api"

If you are using Python Shopify API and getting following error
"Exceeded 4 calls per second for api client. Reduce request rates to resume uninterrupted service."
but want your script to continue working with some timeout after that,
you can use following script from shopify_limits_patch.py.

For that just copy shopify_limits_patch.py to your project and import shopify_limits_patch.

Or if you want to call it implicitly import it, remove last line patch_shopify_with_limits()
and call it before all your shopify calls.

@jorilallo
jorilallo / Flex.js
Created August 17, 2017 20:06
Flexbox component for React
// @flow
import React from 'react';
import styled from 'styled-components';
type GlobalCssValues = 'initial' | 'inherit' | 'unset';
type WrapValue = 'nowrap' | 'wrap' | 'wrap-reverse' | GlobalCssValues;
type JustifyValue =
| 'center'
@tomgross
tomgross / check_coverage.py
Last active April 10, 2019 14:33
Check the coverage of Python tests and compare with previous run in gitlab
# This script checks the coverage and test if it keeps at least the same
# Add this to your .gitlab-ci.yml
#
# coveragetest:
# ...
# cache:
# paths:
# - coverage_value.txt
# script:
# - bin/coverage run bin/test
@JoelQ
JoelQ / README.md
Created October 15, 2015 13:50
Using Shell Scripts for a Better User Experience (source for https://robots.thoughtbot.com/improving-user-experience-with-shell-scripts)

Server scripts

This is the source for the scripts discussed in https://robots.thoughtbot.com/improving-user-experience-with-shell-scripts

Both scripts are in the bin/ directory of the repo that contains all the markdown documents for blog posts. Users run bin/server and everything is automatically set up for them to view a local preview of the blog. bin/server-setup is a dependency of bin/server and is never run directly by users.

Maitre-d is the name of the "blog engine" discussed in the article.