Skip to content

Instantly share code, notes, and snippets.

View fxi's full-sized avatar
🚀
Learning new things.

F.Moser fxi

🚀
Learning new things.
View GitHub Profile
@fxi
fxi / chatgpt.rb
Created December 16, 2022 20:19
ChatGPT generated song
use_bpm 30
define :chorda do |root, type|
case type
when "major"
[root, root+4, root+7]
when "minor"
[root, root+3, root+7]
end
end
{"ABW":["Aruba"],"Aruba":["ABW"],"AFG":["Afghanistan"],"Afghanistan":["AFG"],"AGO":["Angola"],"Angola":["AGO"],"AIA":["Anguilla"],"Anguilla":["AIA"],"ALA":["Åland Islands"],"Åland Islands":["ALA"],"ALB":["Albania"],"Albania":["ALB"],"AND":["Andorra"],"Andorra":["AND"],"ARE":["United Arab Emirates"],"United Arab Emirates":["ARE"],"ARG":["Argentina"],"Argentina":["ARG"],"ARM":["Armenia"],"Armenia":["ARM"],"ASM":["American Samoa"],"American Samoa":["ASM"],"ATA":["Antarctica"],"Antarctica":["ATA"],"ATF":["French Southern Territories"],"French Southern Territories":["ATF"],"ATG":["Antigua and Barbuda"],"Antigua and Barbuda":["ATG"],"AUS":["Australia"],"Australia":["AUS"],"AUT":["Austria"],"Austria":["AUT"],"AZE":["Azerbaijan"],"Azerbaijan":["AZE"],"BDI":["Burundi"],"Burundi":["BDI"],"BEL":["Belgium"],"Belgium":["BEL"],"BEN":["Benin"],"Benin":["BEN"],"BES":["Bonaire, Sint Eustatius and Saba"],"Bonaire, Sint Eustatius and Saba":["BES"],"BFA":["Burkina Faso"],"Burkina Faso":["BFA"],"BGD":["Bangladesh"],"Bangladesh":[
@fxi
fxi / tixy_audio_sound_analyzers.md
Last active December 27, 2020 11:08
Rendering sound analyzers for audio stream in tixy.land #tixy #golf #toy

Rendering from mic stream

Collection of code snippets for tixy.land

  • Render a simple white bar graph. 210 char.
//  Not working on safari, not working using link ( audio context need user interaction )
i?(a.getByteFrequencyData(d),(16-d[x]/18)-y)<0:t||(d=new Uint8Array(16),c=new AudioContext(),navigator.mediaDevices.getUserMedia({audio:a=c.createAnalyser()}).then(s=>{c.createMediaStreamSource(s).connect(a)}))
@fxi
fxi / minimal_working_js.md
Created December 24, 2020 10:45
Minimal working js collection #golf #toy #stuff

Minimal working js collection

Collection of JavaScript code snippets that produce a functional output, in a given context.

  • Print and scroll 'MapX' in console.log, 178 bytes
t=0,c=console,(a=e=>{for(c.clear(),i=0,t+=2,g="",y=0;y<16;y++){for(r="",x=0;x<16;x++)i++,r+=([44191,19797,42545][y+t&7]&1<<x)>0?"🔴":"⚪";g=g+"\n"+r}c.log(g),setTimeout(a,1e3)})();
@fxi
fxi / tixy_webcam_stream.js
Last active December 22, 2020 07:11
Rendering a webcam stream in tixy.land
/**
* Rendering a webcam stream in https://tixy.land, golfing log
*/
/* @frdmsr 415 bytes */
window.a?i?(a[4*x+4*y*s]/255):g():!window.r&&(r=1,s=16,h="height",w="width",d=(()=>document),e=(e=>d().createElement(e)),v=e("video"),c=e("canvas"),cx=(()=>c.getContext("2d")),g=(()=>{cx().drawImage(v,0,0,s,s),a=cx().getImageData(0,0,s,s).data}),c[h]=c[w]=v[h]=v[h]=s,navigator.mediaDevices.getUserMedia({video:1}).then(e=>{v.srcObject=e,v.addEventListener("canplay",g,0),v.play()}).catch(()=>alert("Enable webcam :)")))
/* @aemkei 386 bytes */
top.a?i?a[4*x+4*y*s]/255*1.2-.1:g():!this.r&&(r=1,s=16,h="height",w="width",d=e=>document,e=e=>d().createElement(e),v=e`video`,c=e`canvas`,cx=e=>c.getContext`2d`,g=e=>{cx().drawImage(v,0,0,s,s),a=cx().getImageData(0,0,s,s).data},c[h]=c[w]=v[h]=v[h]=s,navigator.mediaDevices.getUserMedia({video:1}).then(e=>{v.srcObject=e,v.addEventListener("canplay",g,0),v.play()}).catch(e=>alert`🙈`))
@fxi
fxi / app.R
Last active October 13, 2020 10:10
library(shiny)
source('helper.R')
ui = fluidPage(
plotOutput("i"),
sliderInput(
"s",
"range",
min = 0,
max = 1000,
/**
* Custom method for custom view in MapX
* Parameters for onInit and onClose function ;
* @param {Object} o Options
* @param {Object} o.view Map-x view object
* @param {Object} o.map mapbox-gl map object
* @param {String} o.idView If of the view
* @param {String} o.idSource Id of the source
* @param {Element} o.elLegend Element containing the legend
*
@fxi
fxi / metadeta.json
Last active March 5, 2019 15:23
Example of MapX metadata schema and metadata for a specific source
{
"text": {
"title": {
"en": "Artisanal Mines Sites 2015",
"fr": "",
"es": "",
"ru": "",
"zh": "",
"de": "",
"bn": "",
@fxi
fxi / custom_code.js
Last active February 21, 2019 13:56
Cycle through WMS sources in MapX custom code view
/**
* Custom method for custom view in map-x
* Parameters for onInit and onClose function ;
* @param {Object} o Options
* @param {Object} o.view Map-x view object
* @param {Object} o.map mapbox-gl map object
* @param {String} o.idView If of the view
* @param {String} o.idSource Id of the source
* @param {Element} o.elLegend Element containing the legend
*
@fxi
fxi / animate_raster_layers.js
Created February 20, 2019 11:02
Custom code to animate a serie of images in MapX custom code view
/**
* Custom method for custom view in map-x
* Parameters for onInit and onClose function ;
* @param {Object} o Options
* @param {Object} o.view Map-x view object
* @param {Object} o.map mapbox-gl map object
* @param {String} o.idView If of the view
* @param {String} o.idSource Id of the source
* @param {Element} o.elLegend Element containing the legend
*