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
// Paper: https://arxiv.org/pdf/2301.10191 | |
// Article: https://www.quantamagazine.org/computer-scientists-invent-an-efficient-new-way-to-count-20240516/ | |
function generateRandomNumbers(c, n) { | |
let randomNumbers = new Array(c); | |
for (let i = 0; i < randomNumbers.length; i++) { | |
let randomNumber = Math.floor(Math.random() * (n + 1)); | |
randomNumbers[i] = randomNumber; | |
} | |
return randomNumbers; |
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
function trimSilenceFromBuffer(buffer, threshold = 0.001, minSilenceDuration = 0.1) { | |
const sampleRate = Tone.context.sampleRate; | |
const channelData = buffer.getChannelData(0); // Assuming mono audio for simplicity | |
let endOfAudioIndex = channelData.length - 1; | |
let silenceDuration = 0; | |
// Iterate backwards through the buffer | |
for (let i = channelData.length - 1; i >= 0; i--) { | |
const sample = Math.abs(channelData[i]); // Get the absolute value of the sample |
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
{ | |
"purchase": { | |
"id": "i-am-obfuscated", | |
"cart": { | |
"lineItems": [ | |
{ | |
"product": { | |
"sku": "i-am-sku", | |
"name": "hello world", | |
"unitPrice": 5, |
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 React from 'react' | |
import { compose } from 'redux' | |
import { connect } from 'react-redux' | |
import { addToCart } from '../actions' | |
import { fetchProducts } from '../decorators' | |
const mapDispatchToProps = (dispatch) => ({ | |
add (product) { | |
dispatch(addToCart(product)) | |
}, |
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 { BrowserRouter as Router, Route } from 'react-router-dom' | |
import Upsell from './containers/Upsell' | |
import AddonsView from './components/AddonsView' | |
import ExtrasView from './components/Extras' | |
const Addons = Upsell({ | |
view: AddonsView, | |
products: ['shave-butter', 'hair-gel', 'butt-wipes'], | |
}) |
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 React from 'react' | |
import { compose } from 'redux' | |
import { connect } from 'react-redux' | |
import { addToCart } from '../actions' | |
import { fetchProducts } from '../decorators' | |
const mapDispatchToProps = (dispatch) => ({ | |
add (product) { | |
dispatch(addToCart(product)) | |
}, |
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
(function() { | |
// Shim with setTimeout fallback | |
window.requestAnimationFrame = function() { | |
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame || window.oRequestAnimationFrame || function(f) { | |
window.setTimeout(f, 1e3 / 60) | |
} | |
}(); | |
function num_between(n1, n2) { |
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 Ember from 'ember'; | |
export default Ember.Component.extend({ | |
classNames: ['foo', 'bar'], | |
isAwesome: true, | |
isNotAwesome: false, | |
}); |
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 DS from 'ember-data'; | |
export default DS.RESTAdapter.extend({ | |
shouldReloadAll: function() { | |
return true; | |
} | |
}); |
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 Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
NewerOlder