Skip to content

Instantly share code, notes, and snippets.

@ffaerber
ffaerber / XIAO-sense-audiotools.ino
Last active May 31, 2024 08:07
Usage of Seeed Studio XIAO ESP32S3 microphone with arduino-audio-tools
// Usage of Seeed Studio XIAO ESP32S3 microphone with github.com/pschatzmann/arduino-audio-tools
// https://wiki.seeedstudio.com/xiao_esp32s3_sense_mic/
#include "AudioTools.h"
AudioInfo info(16000, 1, 16);
I2SStream i2sStream; // Access I2S as stream
CsvOutput<int16_t> csvStream(Serial);
StreamCopy copier(csvStream, i2sStream); // copy i2sStream to csvStream
@ffaerber
ffaerber / gist:cf52fb7a6046b8b7cefe700d009fab4b
Last active September 21, 2023 07:53
run llama.cpp api local on docker

create a working directory. i use ~/Projects/aimodels than create subdirectory for the model like mkdir ~/Projects/aimodels/huggingface.co/TheBloke and cd ~/Projects/aimodels/huggingface.co/TheBloke now download the model wget https://huggingface.co/TheBloke/Guanaco-13B-Uncensored-GGUF/resolve/main/guanaco-13b-uncensored.Q4_0.gguf

create docker-compose.yaml

version: '3.6'
services:
  llama-cpp-api:
    image: ghcr.io/abetlen/llama-cpp-python:latest
    restart: on-failure
require 'omniauth-oauth2'
module OmniAuth
module Strategies
class Figo < OmniAuth::Strategies::OAuth2
# Give your strategy a name.
option :name, "figo"
# This is where you pass the options you would pass when
# initializing your consumer from the OAuth gem.
json.lounge do
json.id @lounge.id
json.name @lounge.name
json.client @lounge.client
json.logo @lounge.logo
json.description @lounge.description
json.created_at @lounge.created_at
json.updated_at @lounge.updated_at
json.tags @lounge.tag_list
numbers = [5, 3, 23, 6, 7, 0, 1, 25, 11, 19, 20]
chartHeight = 300
chart = d3.select("body")
.append("svg")
.attr("width", "100%")
.attr("height", "100%")
bars = chart.selectAll("g.bar").data(numbers).enter()
.append("g")
#!/usr/bin/env ruby
require 'httparty'
require 'json'
environment_id = %x( echo "$RD_OPTION_ENVIRONMENT_ID" )
rails_auth_token = %x( echo "$RD_OPTION_RAILS_AUTH_TOKEN" )
user_email = %x( echo "$RD_OPTION_USER_EMAIL" )
url = "http://localhost:3000/environments/#{environment_id}.json?user_email=#{user_email}&user_token=#{rails_auth_token}"
@ffaerber
ffaerber / _new.html.haml
Last active August 29, 2015 14:06
simple_form submit modal with remote:true against inherited_resources and working form validation in rails.
.modal-dialog
.modal-content
.modal-header
%button.close{"aria-hidden" => "true", "data-dismiss" => "modal", type: "button"} ×
%h4.modal-title= t'new_node'
.modal-body
= simple_form_for @node, remote: true do |f|
- value = params[:environment_id].nil? ? {} : { value: params[:environment_id] }
= f.input :environment_id, as: :hidden, input_html: {}.merge(value)
= render 'nodes/form_fields', f: f
@ffaerber
ffaerber / rubybuilt.rb
Created July 3, 2014 08:17
ruby build chef
include_recipe 'ruby_build'
file "/etc/gemrc" do
content <<-EOS
install: --no-rdoc --no-ri
update: --no-rdoc --no-ri
EOS
owner "root"
mode 0644
> db.measurements.find()
{ "_id" : ObjectId("53203553666661072f000000"), "meter_id" : 1, "timestamp" : ISODate("2014-03-12T00:00:00Z"), "wh" : 1234136 }
{ "_id" : ObjectId("53203553666661072f010000"), "meter_id" : 1, "timestamp" : ISODate("2014-03-12T00:01:00Z"), "wh" : 1234149 }
{ "_id" : ObjectId("53203553666661072f020000"), "meter_id" : 1, "timestamp" : ISODate("2014-03-12T00:02:00Z"), "wh" : 1234162 }
{ "_id" : ObjectId("53203553666661072f030000"), "meter_id" : 1, "timestamp" : ISODate("2014-03-12T00:03:00Z"), "wh" : 1234175 }
{ "_id" : ObjectId("53203553666661072f040000"), "meter_id" : 1, "timestamp" : ISODate("2014-03-12T00:04:00Z"), "wh" : 1234188 }
{ "_id" : ObjectId("53203553666661072f050000"), "meter_id" : 1, "timestamp" : ISODate("2014-03-12T00:05:00Z"), "wh" : 1234201 }
{ "_id" : ObjectId("53203553666661072f060000"), "meter_id" : 1, "timestamp" : ISODate("2014-03-12T00:06:00Z"), "wh" : 1234214 }
{ "_id" : ObjectId("53203553666661072f070000"), "meter_id" : 1, "timestamp" : ISODate("2014-03-12T00:07
db.measurements.aggregate([
{ "$match" : { "timestamp": { "$gte": ISODate('2014-03-12 00:00:00'), "$lt": ISODate('2014-03-12 23:59:59') } } },
{ "$project": {
"wh": 1,
"hourly": { "$hour": "$timestamp" }
}},
{ "$sort": { "hourly": 1 } },
{ "$group": {
"_id": "$hourly",
"firstReading": { "$first": "$wh" },