nmse = 0.042
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import crypto from 'crypto'; | |
export default async (req, res) => { | |
try { | |
if (req.method !== 'POST') { | |
return res.status(404).send(); | |
} | |
if (req.path.endsWith('/webhook')) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function storeganiseApi({ apiUrl, addonId }) { | |
function fetchSg(path, { | |
method = 'GET', | |
body, | |
} = {}) { | |
const url = `${apiUrl}/v1/admin/${path}`; | |
return fetch(url, { | |
method, | |
headers: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fetchJson(path, {method, body}) { | |
return fetch(`${API_BASE_URL}${path}`, { | |
method, | |
// credentials: 'include', // Use either 1. this if using cookies-based authentication | |
headers: { | |
// either nothing (if using cookies (requires same domain) | |
// Authorization: `Bearer ${localStorage.getItem('access_token')}`, // or this (client-side) | |
// Authorization: `ApiKey ${process.env.SG_API_KEY}`, // or access token authentication (server-side) | |
...body && {'Content-Type': 'application/json'}, | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$include /etc/inputrc | |
# may need export INPUTRC=~/.inputrc note: use ctrl+v to debug readline | |
# set echo-control-characters off | |
set show-all-if-ambiguous on | |
# set history-preserve-point on | |
"\e[5~": beginning-of-history |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import Html from '../components/html'; // wraps pages into <html> and some common layout | |
// you might want a webpack.config.js at least for styles | |
// typically we use a sass loader, and also @emotion/react in our components | |
// Html will take care to add <link> for built ./build/**/*.css | |
// and <script> for built ./build/**/*.js if any, you might even inline it <script>{content}</script> if short | |
// It's also possible to build css/js assets per page, we didn't do that | |
export async function getServerSideProps({ req }) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http'); | |
const fetch = require('node-fetch'); | |
const getToken = () => new Promise((resolve, reject) => { | |
const server = http.createServer(async (req, res) => { | |
res.end(); | |
const params = new URLSearchParams(req.url.slice(1)); | |
console.log('rec', req.url, params); | |
if (params.has('code')) { | |
resolve(params.get('code')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scipy import * | |
#from scipy.linalg import * | |
from pylab import * | |
class SVM: | |
def train(self, X, Y, kernel, C, tol = 1e-3, max_passes = 5): | |
m = size(X, 0) | |
n = size(X, 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const API_URL = 'https://..'; // Your API base url | |
// returns true for plain object literals, like {foo: 'bar'}, false for other cases, like instances of classes, like lodash.isPlainObject | |
const isPlainObject = obj => obj && Object.getPrototypeOf(obj) === Object.prototype || Object.getPrototypeOf(obj) === null; | |
export function fetchJson(url, { body, headers, ...o } = {}) { | |
const isJson = isPlainObject(body); // most of the time we send plain 'json' objects | |
return fetch(url[0] === '/' ? API_URL + url : url, { | |
headers: { | |
...isJson && {'Content-Type': 'application/json'}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('dotenv/config'); | |
const fs = require('fs-extra'); | |
const webpack = require('webpack'); | |
const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin'); | |
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | |
fs.emptyDirSync(__dirname + '/build'); | |
fs.copySync(__dirname + '/public/', __dirname + '/build/', { | |
dereference: true, |
NewerOlder