Skip to content

Instantly share code, notes, and snippets.

View RichardBray's full-sized avatar
😎
Fix bug , drink milkshake, code feature, repeat.

Richard Oliver Bray RichardBray

😎
Fix bug , drink milkshake, code feature, repeat.
View GitHub Profile
from tornado.web import Application, RequestHandler
from tornado.ioloop import IOLoop
class HelloHandler(RequestHandler):
def get(self):
self.write({'message': 'hello world'})
def make_app():
urls = [("/", HelloHandler)]
return Application(urls)
@RichardBray
RichardBray / base64pdf.js
Last active July 21, 2021 05:26
Downloading a base 64 pdf code
/**
* Creates an anchor element `<a></a>` with
* the base64 pdf source and a filename with the
* HTML5 `download` attribute then clicks on it.
* @param {string} pdf
* @return {void}
*/
function downloadPDF(pdf) {
const linkSource = `data:application/pdf;base64,${pdf}`;
const downloadLink = document.createElement("a");
@RichardBray
RichardBray / webpack.config.js
Created January 10, 2018 13:44
Styles rule to module
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
use: [
{
loader: "css-loader",
options: {
minimize: true
}
},
@RichardBray
RichardBray / style.scss
Created January 10, 2018 13:42
some simple code for style.scss
$background-grey: #f3f3f3;
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
line-height: 1.3rem;
background-color: $background-grey;
}
@RichardBray
RichardBray / webpack.config.js
Last active January 10, 2018 13:28
resolve and devtool
devtool: "source-map",
resolve: {
extensions: [".js", ".ts", ".tsx"]
}
@RichardBray
RichardBray / index.tsx
Created January 10, 2018 13:15
Index with App component
import * as React from "react";
import * as ReactDOM from "react-dom";
import { App } from "./components/App";
const ROOT = document.querySelector(".container");
ReactDOM.render(<App name="Jamala" />, ROOT);
@RichardBray
RichardBray / App.tsx
Created January 10, 2018 13:04
first bit of content for app.tsx
import * as React from "react";
export class App extends React.Component<any, any> {
render() {
return <h1>Hello, {this.props.name}</h1>;
}
}
module: {
rules: [
{
test: /\.tsx?$/,
loader: "awesome-typescript-loader"
},
{
enforce: "pre",
test: /\.js$/,
loader: "source-map-loader"
@RichardBray
RichardBray / webpack.config.js
Created January 10, 2018 12:33
first addition to the plugin
plugins: [
new HtmlWebpackPlugin({
template: "./index.html"
})
]
@RichardBray
RichardBray / tsconfig.json
Created January 10, 2018 11:12
Simple ts configuraiton
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"jsx": "react",
"module": "commonjs",
"noImplicitAny": true,
"outDir": "./build/",
"preserveConstEnums": true,
"removeComments": true,
"sourceMap": true,