Skip to content

Instantly share code, notes, and snippets.

View jakiestfu's full-sized avatar
🌺

Jacob Kelley jakiestfu

🌺
View GitHub Profile
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
@jakiestfu
jakiestfu / git_rdiff.sh
Last active January 4, 2024 20:42
git rdiff
git config --global alias.rdiff '!g() { origin=$(git config --get remote.origin.url | sed "s/git@/https:\/\//g" | sed "s/.com:/.com\//g"); url=${origin/.git/\/commit\/$(git rev-parse HEAD)}; open $url; }; g'
@jakiestfu
jakiestfu / aliases.sh
Last active July 30, 2019 19:51
Useful Git Aliases
# Git Destroy
# Deletes a branch locally and on the origin
# git destroy <branch>
git config --global alias.destroy '!g() { git branch -D $1 && git push origin $1 --delete; }; g'
# Git Circle CI
# Opens the projects builds in Circle
# git cci
git config --global alias.cci '!g() { branch=`git rev-parse --abbrev-ref HEAD`; top_level=`git rev-parse --show-toplevel`; repo=`basename $top_level`; url="https://circleci.com/gh/MakerStudios/$repo/tree/$branch"; open $url; }; g'
{
"purchase": {
"id": "i-am-obfuscated",
"cart": {
"lineItems": [
{
"product": {
"sku": "i-am-sku",
"name": "hello world",
"unitPrice": 5,
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))
},
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))
},
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'],
})
@jakiestfu
jakiestfu / ko-money.js
Last active February 14, 2018 10:46
Used to display formatted money via Knockout binding
(function(){
var toMoney = function(num){
return '$' + (num.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,') );
};
var handler = function(element, valueAccessor, allBindings){
var $el = $(element);
var method;
(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) {
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['foo', 'bar'],
isAwesome: true,
isNotAwesome: false,
});