Skip to content

Instantly share code, notes, and snippets.

View nchelaru's full-sized avatar

Nancy Chelaru nchelaru

View GitHub Profile
@nchelaru
nchelaru / admonition_box.html
Last active January 27, 2019 03:25
[Admonition box] #Frills #HTML #Formatting
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
div {
margin-bottom: 15px;
padding: 4px 12px;
}
.info {
@nchelaru
nchelaru / RStudio_SQLite.r
Last active January 27, 2019 13:23
[Connect to SQLite database in Rstudio] #R #SQLite #RStudio
## Import library
library(RSQLite)
## Connect to an existing database
Customers <- dbConnect(SQLite(), dbname = 'Customers.sqlite')
## Create and connect to a "virtual" in-memory database
Food <- dbConnect(SQLite())
# In `settings.py`:
```python
INSTALLED_APPS = [
...
'django_plotly_dash.apps.DjangoPlotlyDashConfig',
...
]
```
@nchelaru
nchelaru / dpd-template
Created April 19, 2019 17:17
For a plotly dash app named "SimpleExample". See https://github.com/nd823/django-plotly-dash-modified.
{% load plotly_dash %}
{% plotly_app name="SimpleExample" %}
@nchelaru
nchelaru / modified_sections_settings
Created April 19, 2019 17:35
Replace the relevant sections in "settings.py" with content in the snippet, for use with django-plotly-dash.
```python
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'grocery.apps.GroceryConfig',
'django_plotly_dash.apps.DjangoPlotlyDashConfig',
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import pandas as pd
import plotly.graph_objs as go
df = pd.read_csv(
'https://raw.githubusercontent.com/plotly/'
from django.shortcuts import render
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import pandas as pd
import plotly.graph_objs as go
def add_datepart(df, fldname, drop=True, time=False):
"Helper function that adds columns relevant to a date."
fld = df[fldname]
fld_dtype = fld.dtype
if isinstance(fld_dtype, pd.core.dtypes.dtypes.DatetimeTZDtype):
fld_dtype = np.datetime64
if not np.issubdtype(fld_dtype, np.datetime64):
df[fldname] = fld = pd.to_datetime(fld, infer_datetime_format=True)
targ_pre = re.sub('[Dd]ate$', '', fldname)
df.to_feather('filename')
df = pd.read_feather('path/to/feather_file')
##Import library
library(RSQLite)
##Connect to an existing database
Customers <- dbConnect(SQLite(), dbname = 'Customers.sqlite')
##Create and connect to a "virtual" in-memory database
Food <- dbConnect(SQLite())
## List all the tables currently in the database