Skip to content

Instantly share code, notes, and snippets.

Avatar

Mikela glassresistor

View GitHub Profile
@glassresistor
glassresistor / app.py
Created Sep 10, 2020
Spliting a dash app into modules
View app.py
from page_1 import *
from page_2 import *
server = app.server
if __name__ == '__main__':
app.run_server(debug=True)
View failure.py
==================================================================================================== FAILURES =====================================================================================================
_________________________________________________________________________________________ test_custom_view_with_ordering __________________________________________________________________________________________
token = <Token: 5502f6196a82da5016b0c5b58ee83cd02968c6d9>
examplefortesting = [<ExampleForTesting: ExampleForTesting object (150)>, <ExampleForTesting: ExampleForTesting object (151)>, <ExampleFor...bject (152)>, <ExampleForTesting: ExampleForTesting object (153)>, <ExampleForTesting: ExampleForTesting object (154)>]
@pytest.mark.django_db
def test_custom_view_with_ordering(token, examplefortesting):
"""Test ordering query returns csv with specified order"""
View wtf.py
(data_warehouse)
┌───=[ mikela :: debian -( 0 )-[ ~/pivot/data_warehouse ]
└──(python --version
Python 3.7.1
(data_warehouse)
┌───=[ mikela :: debian -( 0 )-[ ~/pivot/data_warehouse ]
└──(ipython
Python 3.7.1 (default, Oct 23 2018, 19:19:42)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.1.1 -- An enhanced Interactive Python. Type '?' for help.
View gist:d38c37a4ab6ac3b9fc6a7e4c10082fbf
- name: Compile assets
shell: 'source /home/rails/.bashrc && env | grep RBENV'
args:
chdir: "/home/rails/lims"
executable: /bin/sh
become_user: rails
View admin.py
from django.contrib import admin
from django.apps import apps
from bulk_importer import models
BULKABLE_MODELS = []
class BulkableAdmin(admin.ModelAdmin):
readonly_fields = ('created_at', 'updated_at', 'imported_from')
View form.py
def get_form_from_model_name(full_model_name):
app_label, model_name = full_model_name.split(".")
form_model = apps.get_model(app_label, model_name)
fields = form_model._meta.fields
name_fields = []
for field in fields:
if field.related_model and (issubclass(
field.related_model,
bi_models.NamedBulkable) or issubclass(
View gist:ecfbb08b5b26c6099c7bed4cee62c888
create user django with password 'password';
create schema django authorization django;
create user rails with password 'password';
create schema rails authorization rails;
create extension hstore;
create extension pg_trgm schema rails;
grant USAGE on SCHEMA rails to django;
ALTER DEFAULT PRIVILEGES IN SCHEMA rails revoke all on tables from django;
ALTER DEFAULT PRIVILEGES IN SCHEMA rails grant select on tables to django;
ALTER DEFAULT PRIVILEGES IN SCHEMA rails revoke all on sequences from django;
View gist:ae40c7bc8971537e388a74cf1ff7cc7a
data_warehouse=# \ddp
Default access privileges
Owner | Schema | Type | Access privileges
--------+--------+-------+-------------------
mikela | rails | table | django=r/mikela
(1 row)
View gist:2c1e5c4a999eb9d48b555f129eb2aad2
CREATE OR REPLACE FUNCTION remove_words(message text) RETURNS SETOF text AS $$
BEGIN
RETURN QUERY select * from regexp_split_to_table(message, E'\\s+') except select boring_words.word from boring_words where boring_words.word = ANY(regexp_split_to_array(message, E'\\s+'));
END;
$$ LANGUAGE plpgsql;
View gist:b14b3707cb8b0b21ec04219ac7e94916
-rw-r--r-- 1 root root 29M Aug 1 18:21 initrd.img-3.16.0-4-amd64.old-dkms
-rw-r--r-- 1 root root 32M Nov 21 10:47 initrd.img-4.9.0-0.bpo.2-amd64.old-dkms
-rw-r--r-- 1 root root 32M Nov 21 10:29 initrd.img-4.9.0-0.bpo.3-amd64.old-dkms