Skip to content

Instantly share code, notes, and snippets.

View svschannak's full-sized avatar

Sven Schannak svschannak

View GitHub Profile
@svschannak
svschannak / progressChartVictoryPieWithText.js
Created August 22, 2017 12:37
Progess Chart with Victory Pie and Text in the center of the pie chart
<svg width={200} height={200}>
<text x={100} y={110} textAnchor="middle" >
{this.state.metric}%
</text>
<VictoryPie
padAngle={0}
// used to hide labels
labelComponent={<span/>}
innerRadius={70}
width={200} height={200}
@svschannak
svschannak / progressChartVictoryPieStandard.js
Created August 22, 2017 12:29
Progess Chart with Victory Pie
import {VictoryPie, VictoryTheme} from 'victory';
<VictoryPie
padAngle={0}
// used to hide labels
labelComponent={<span/>}
innerRadius={70}
width={200} height={200}
data={[{'key': "", 'y': this.state.metric}, {'key': "", 'y': (100-this.state.metric)} ]}
colorScale={["#19B3A6", "#EEEEEE" ]}
@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
@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_example_static
Last active May 11, 2017 10:24
Example caddy file for serving static sites
my-domain.com, www.my-domain.com
curl https://getcaddy.com | bash
@svschannak
svschannak / private_named_function.js
Created May 10, 2017 12:51
Defining a private named function in JS
const outerFunctionName = function innerFunctionName() {}
@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) => {
def items(self):
return Event.objects.filter(user=request.user).order_by('-date')
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