Skip to content

Instantly share code, notes, and snippets.

View svschannak's full-sized avatar

Sven Schannak svschannak

View GitHub Profile
# views.py
class EventFeed(ICalFeed):
"""
A simple event calender
"""
product_id = '-//example.com//Example//EN'
timezone = 'UTC'
file_name = "event.ics"
class ICalFeed(Feed):
# comments
feed_type = feedgenerator.DefaultFeed
def __call__(self, request, *args, **kwargs):
"""
Copied from django.contrib.syndication.views.Feed
Supports file_name as a dynamic attr.
"""
class EventFeed(ICalFeed):
"""
A simple event calender
"""
product_id = '-//example.com//Example//EN'
timezone = 'UTC'
file_name = "event.ics"
def __call__(self, request, *args, **kwargs):
self.request = request
def items(self):
return Event.objects.filter(user=request.user).order_by('-date')
@svschannak
svschannak / example_calling_parent_function.js
Created May 10, 2017 12:48
Example of calling a parent function in JavaScript using private function names.
export function mainFunction() {
const returnFunction = function fetchFunction(dispatch) {
const fetchConfig = {
url: '/api/endpoint/',
httpMethod: 'get',
successStatusCode: 200,
successCallback: (res) => {
//execute if successful
},
errorCallback: (err) => {
@svschannak
svschannak / private_named_function.js
Created May 10, 2017 12:51
Defining a private named function in JS
const outerFunctionName = function innerFunctionName() {}
curl https://getcaddy.com | bash
@svschannak
svschannak / caddy_example_static
Last active May 11, 2017 10:24
Example caddy file for serving static sites
my-domain.com, www.my-domain.com
@svschannak
svschannak / caddy_static_site.service
Created May 11, 2017 10:31
Caddy Server with systemd
[Unit]
Description=Caddy Server startup script for static website
[Service]
WorkingDirectory=/code/static-website/
ExecStart=/usr/local/bin/caddy
Restart=always
[Install]
WantedBy=multi-user.target
@svschannak
svschannak / caddy_systemd_init.sh
Last active May 11, 2017 10:37
Example code to init caddy for systemd
cp caddy_static_site.service /etc/systemd/system/caddy_static_site.service
systemctl daemon-reload
systemctl enable caddy_static_site.service
systemctl start caddy_static_site.service
sudo systemctl status caddy_static_site.service # get status of the service - should be active