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 flask import Flask | |
from flask import request | |
from flask import make_response | |
from json import loads, dumps | |
app = Flask(__name__) | |
@app.route("/add2cart", methods=["POST"]) | |
def add2cart(): | |
cart = {} # default value, can be loaded from cookies | |
cookies = request.headers.get("Cookie", "") |
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 flask import Flask | |
from flask import request | |
from flask import make_response | |
from json import loads, dumps | |
import random, string | |
app = Flask(__name__) | |
carts = { # server-side application state | |
'deadbeef' : {'Marchewka' : 4} |
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 JWT_SECRET=something | |
# $ python3 -m pip install pyjwt | |
import jwt, os | |
import datetime | |
SECRET = os.getenv("JWT_SECRET") | |
NOW = datetime.datetime.now(tz=datetime.timezone.utc) | |
def user_token(uid, role, seconds=60): | |
dt = datetime.timedelta(seconds=seconds) |
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
# To assure reproducability, the given Redis database (db=0) | |
# !!! is CLEARED !!! each time the application starts | |
# | |
# $ export JWT_SECRET=something | |
# $ python3 -m pip install flask pyjwt redis | |
# $ export REDIS_PASSWORD=verycomplex | |
# $ export REDIS_PORT=6379 | |
# $ export REDIS_HOST=myhost.com | |
from os import getenv | |
from flask import Flask, g |
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 json import dumps, loads | |
class Price: | |
def __init__(self, db): | |
self.db = db | |
def __getitem__(self, item): | |
price = self.db.hget("price", item) | |
if price: | |
return int(price) |
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
<!-- | |
Put this file in ~/Library/LaunchAgents/com.example.KeyRemapping.plist to | |
automatically remap your keys when macOS starts. | |
See https://developer.apple.com/library/archive/technotes/tn2450/_index.html for | |
the key "usage IDs". Take the usage ID and add 0x700000000 to it before putting it | |
into a source or destination (HIDKeyboardModifierMappingSrc and | |
HIDKeyboardModifierMappingDst respectively). | |
--> | |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
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("wave-equation.jl") | |
function quadmesh(a, b, Nx, Ny) | |
NUM_EDGES = 2(Nx*Ny) + Nx + Ny | |
NUM_ELEMS = Nx * Ny | |
el2edd = repeat([+1 +1 -1 -1], NUM_ELEMS) | |
el2ed = zeros(Int64, NUM_ELEMS, 4) | |
for jj = 1:Ny | |
for ii = 1:Nx |
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 H = 20 | |
const W = 20 | |
const f = zeros(9, H, W) | |
const rho = ones(H, W) | |
struct Lattice | |
f :: Array{Float64, 3} | |
end | |
const lattice = Lattice(f) |
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
ε_0 = 8.85418781e-12 # vacuum permittivity [F/m] | |
μ_0 = 1.256637062e-6 # vacuum permeability [H/m] | |
c = 299_792_458. # speed of light [m/s] | |
NR = 101 # number of grid points along radial direction [1] | |
NZ = 101 # number of grid points along axial direction [1] | |
RADIUS = 0.010 # radius along r-axis [m] | |
LENGTH = 0.010 # lenght along z-axis [m] | |
DZ = LENGTH / (NZ-1) # cell-size along axial direction [m] | |
DR = RADIUS / (NR-1) # cell-size along radial direction [m] |
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
#!/bin/sh | |
OUTPUT_DIR="/" | |
MAX_PID=65535 | |
CGROUP_NAME="xyx" | |
CGROUP_MOUNT="/tmp/cgrp" | |
PAYLOAD_NAME="${CGROUP_NAME}_payload.sh" | |
PAYLOAD_PATH="${OUTPUT_DIR}/${PAYLOAD_NAME}" | |
OUTPUT_NAME="${CGROUP_NAME}_payload.out" | |
OUTPUT_PATH="${OUTPUT_DIR}/${OUTPUT_NAME}" |
OlderNewer