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
class WebSynthProcessor extends AudioWorkletProcessor { | |
constructor(options) { | |
super(options); | |
this.cycler = 0; | |
this.transport = 0; | |
this.port.onmessage = event => this.onmessage(event.data); | |
console.log(sampleRate); | |
} |
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
let startBtn = document.getElementById('start-sound'); | |
async function setup() { | |
const bin = await WebAssembly.compileStreaming(await fetch('/www/wasm_demo.wasm')); | |
// const buf = await bin.arrayBuffer(); | |
let context = new AudioContext(); | |
console.log("adding module"); | |
await context.audioWorklet.addModule('processor.js'); | |
let node = new AudioWorkletNode(context, 'web-synth-proto'); |
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
#!/bin/bash | |
# Run these commands after creating your service file to get it installed and running. | |
# Once the service file is finished, copy it to the correct directory. | |
# In Ubuntu based systems, this is usually /etc/systemd/system. | |
sudo cp postgres.service /etc/systemd/service | |
# Now try starting the service: | |
sudo systemctl start postgres.service |
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
//Import all the things | |
class AwesomePopup extends React.Component { | |
state = { | |
results: [], | |
value: '' | |
} | |
onSearchChange = (e, {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
<form id='form'> | |
<label for="name">Name:</label> | |
<input type="text" name="name" placeholder="Please enter a name"> | |
<label for='avatar'>Image:</label> | |
<input type="file" name="avatar"> | |
<input type="submit" value="Submit new User"> | |
</form> |
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
def create | |
#If you set up your frontend request properly, params[:avatar] will be an UploadedFile instance, which is what we want | |
user = User.new(name: params[:name], avatar: params[:avatar]) | |
#passing the file in to the constructor causes ActiveStorage to attach the file automatically. | |
if user.save | |
puts "The user saved successfully" | |
render json: user | |
else | |
puts "The user failed to save" | |
render json: {message: "Error"} |
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
document.querySelector("#form").addEventListener(e => { | |
e.preventDefault() | |
//Get the file from the file input type | |
const file = e.target['avatar'].files[0] | |
const name = e.target['name'].value | |
const formData = new FormData() | |
//append the file directly to formData. It's read in automatically | |
formData.append('avatar', file) | |
formData.append('name', name) |
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
def create | |
user = User.new(name: params[:name]) | |
user.avatar.attach(params[:avatar]) | |
if user.save | |
puts "The user saved successfully" | |
render json: user | |
else | |
puts "The user failed to save" | |
render json: {message: "Error"} | |
end |
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
class User < ApplicationRecord | |
has_one_attached :avatar | |
end |
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
document.querySelector("#form").addEventListener('submit', (e) => { | |
e.preventDefault() | |
const file = e.target['file'].files[0] | |
const reader = new FileReader(); | |
reader.addEventListener('load', (e) => { | |
console.log(e) | |
console.log('The data is', e.target.result) | |
fetch("http://localhost:3000/images", { |
NewerOlder