This file contains 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
define PROXY_FN | |
export async function onRequest(context) { | |
const { request, params, env } = context; | |
const url = new URL(request.url); | |
url.host = env.API_HOST; | |
url.pathname = params.path.join('') === 'json' ? `/api/json` : params.path.join('/'); | |
if (request.method === 'POST' && !request.headers.get('Content-Type')) { | |
const headers = Object.fromEntries(request.headers.entries()) | |
return fetch(url, { | |
method: request.method, |
This file contains 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
group = "com.tungdao.sample" | |
extra["spring.version"] = "5.1.3.RELEASE" | |
extra["spring.boot.version"] = "2.1.1.RELEASE" | |
extra["spring.cloud.version"] = "Greenwich.RC2" | |
plugins { | |
java | |
idea | |
id("org.springframework.boot") version "2.1.1.RELEASE" |
This file contains 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 Sequelize = require('sequelize') | |
const sequelize = new Sequelize({ | |
dialect: 'sqlite', | |
storage: 'db.sqlite3' | |
}) | |
const Product = sequelize.define('product', { | |
name: Sequelize.STRING | |
}) |
This file contains 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 xlsx = require('xlsx') | |
const table = xlsx.readFile('sample.xlsx', { cellStyles: true }) | |
const sheet = table.Sheets[table.SheetNames[0]]; | |
console.log(sheet) | |
// sheet['C10'] = { t: 's', v: 'Test update value' } | |
const addCell = (sheet, cell, value) => { | |
sheet[cell] = Object.assign({}, sheet[cell], value) |
This file contains 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 functools import reduce | |
# count | |
reduce(lambda i, _: i + 1, [1, 2, 3, 4, 5, 6, 2, 3], 0) | |
# max | |
reduce(lambda a, b: a if a > b else b, [1, 2, 3, 4, 5, 6, 2, 3]) | |
# min | |
reduce(lambda a, b: a if a < b else b, [1, 2, 3, 4, 5, 6, 2, 3]) |
This file contains 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
contract RaiseFund { | |
address public owner; | |
uint public target; | |
uint public total; | |
bool public ended; | |
struct Donation { |
This file contains 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
#!/usr/bin/env stack | |
-- stack --resolver lts-12.0 --install-ghc runghc --package mtl --package resource-pool --package mysql-simple | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
import Control.Monad.Reader | |
import Data.Pool | |
import Database.MySQL.Simple |
This file contains 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 Ractive = require('ractive') | |
const rcu = require('rcu') | |
const typescript = require('typescript') | |
rcu.init(Ractive) | |
class RactivePlugin { | |
constructor(options) { |
This file contains 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
{-# OPTIONS_GHC -fno-warn-orphans #-} | |
module Servant.Selda where | |
import Data.Pool | |
import Database.Selda | |
import Database.Selda.Backend | |
import Database.Selda.PostgreSQL (pgOpen') | |
import RIO | |
import Servant |
This file contains 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 parsy import Parser, Result | |
class Text(object): | |
'''Structure to contain all the parts that the parser does not understand. | |
A better name would be Whitespace | |
''' | |
def __init__(self, text=''): | |
self.text = text |
NewerOlder