Skip to content

Instantly share code, notes, and snippets.

View ar7n's full-sized avatar
🪲
working hard

Arseny Sysolyatin ar7n

🪲
working hard
View GitHub Profile
@ar7n
ar7n / smoth-page-loader.js
Created April 22, 2016 13:16
Smooth page loader. Fade out and fade in for all pages.
!function() {
var overlay;
var timeout = setInterval(function(){
if (document.body) {
var style = document.createElement('style');
style.innerText = '@keyframes preloader-spin {from {transform: rotate(0deg);} to {transform: rotate(360deg);}}';
document.head.appendChild(style);
overlay = document.createElement('div');
overlay.style.cssText = "position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 1000; background: #ffffff; opacity: 1; transition: opacity 0.3s ease-in, z-index 0.3s step-end";
var preloader = document.createElement('img');
@ar7n
ar7n / API-Auth-With-KeystoneJS.md
Created November 20, 2016 13:11 — forked from JedWatson/API-Auth-With-KeystoneJS.md
API Auth with KeystoneJS

To implement API authentication in KeystoneJS, you need the following:

For key based authentication

  • Middleware that validates the key in the request body or a header

For session based authentication

  • An endpoint that handles signin
  • An endpoint that handles signout
@ar7n
ar7n / Countries.js
Created November 20, 2016 13:11 — forked from JedWatson/Countries.js
Example of how to use the filters option for Relationship fields
// A global file to provide the countries and cities
exports.countries = [{
name: 'Australia',
cities: ['Melbourne', 'Sydney', 'Canberra']
}, {
name: 'España',
cities: ['Madrid', 'Barcelona', 'Sevilla']
}, {
name: 'Italia',
@ar7n
ar7n / README.md
Created December 13, 2018 11:48 — forked from phpdude/README.md

Simplest Async Email Backend for Django

What is this?

It is simplest email backend for Django which supports async email delivery in parallel threads. Keep it simple! It has various analogs, you can google for it yourself.

Requirements

Django async email backend requires futures library. So you need to install it with pip install futures.

@ar7n
ar7n / create-db.sql
Created February 11, 2019 08:41
Create Postgres DB with RU locale
CREATE DATABASE "dbname"
WITH OWNER "postgres"
ENCODING 'UTF-8'
LC_COLLATE = 'ru_RU.UTF-8'
LC_CTYPE = 'ru_RU.UTF-8'
TEMPLATE = template0;
from django.db import connection
def idseq(model_class):
return '{}_id_seq'.format(model_class._meta.db_table)
def get_next_id(model_class):
cursor = connection.cursor()
sequence = idseq(model_class)
cursor.execute("select nextval('%s')" % sequence)
row = cursor.fetchone()