Skip to content

Instantly share code, notes, and snippets.

View trouni's full-sized avatar

Trouni trouni

  • Tokyo, teaching APIs to #1508
View GitHub Profile
@trouni
trouni / manifest.json
Last active August 31, 2023 08:30
PWA Deep-linking (Android only, as of August 2023)
// Add these parameters to your PWA manifest.json file
{
// ...
"scope_url": "https://www.myapp.com/",
"start_url": "https://www.myapp.com/",
"intent_filters": {
"scope_url_scheme": "https",
"scope_url_host": "www.myapp.com",
"scope_url_path": "/"
}
@trouni
trouni / stimulusjs_cheatsheet.md
Last active November 20, 2023 13:14
Stimulus.js Cheatsheet

Cheat Sheet: Using Stimulus.js in Rails

Create and Connect a Stimulus Controller

  1. Create a new Stimulus controller file, either:
  • with rails g stimulus my_feature, or
  • by manually adding a file in the controllers directory of your Rails application, e.g., app/javascript/controllers/my_feature_controller.js.
  1. The controller file should define your Stimulus controller class:
@trouni
trouni / lw_olist_pythonpath.sh
Last active July 26, 2023 04:15
Add Olist to PYTHONPATH - AirLiquide DataStudio
#!/bin/bash
cd /home/ec2-user/SageMaker/code/
# Get the first entry in the current directory
gh_username=$(ls -A1 | grep -m1 "^[^.]" | head -n1)
echo "export PYTHONPATH=\"~/SageMaker/code/$gh_username/data-analyst-challenges/04-Decision-Science:\$PYTHONPATH\"" >> ~/.bashrc
exec bash
echo "Successfully added the Decision Science folder to the PYTHONPATH. Good luck with your challenges! 💪"
@trouni
trouni / lw_olist_pythonpath.sh
Last active July 25, 2023 03:06
Add the Decision Science folder to the PYTHON PATH
#!/bin/bash
# Get the remote URL of the 'origin' remote
remote_url=$(git config --get remote.origin.url)
# Function to extract username from 'https://' URL
extract_username_from_https() {
# Remove 'https://' and trailing '.git' from the URL
url_without_protocol=${remote_url#https://}
url_without_protocol=${url_without_protocol%.git}
@trouni
trouni / get_repo_username.sh
Last active July 25, 2023 02:55
Get username from `origin` remote repository URL
#!/bin/bash
# Get the remote URL of the 'origin' remote
remote_url=$(git config --get remote.origin.url)
# Function to extract username from 'https://' URL
extract_username_from_https() {
# Remove 'https://' and trailing '.git' from the URL
url_without_protocol=${remote_url#https://}
url_without_protocol=${url_without_protocol%.git}
@trouni
trouni / elasticsearch-setup-apple-macbook-pro-m1.md
Created April 12, 2023 13:43 — forked from todgru/elasticsearch-setup-apple-macbook-pro-m1.md
Install Elasticsearch 7.x on Apple Macbook Pro M1 Ventura 13.2

Elasticsearch Setup Apple MacBook Pro M1

Apple MacBook Pro M1, 32 GB, Ventura 13.2

Documentation based on comments in this Github Elasticsearch issue.

Install Homebrew

@trouni
trouni / _loader.rb
Last active November 22, 2022 02:37
Real Japanese addresses seeds
require 'yaml'
require 'open-uri'
addresses_url = 'https://gist.githubusercontent.com/trouni/599e03440e2552e803c54c62916f874c/raw/cc7aff8deeb27c3f22ee501b6723766a8cb68f2b/addresses.yml'
serialized_addresses = URI.open(addresses_url).read
addresses = YAML.load(serialized_addresses)
@trouni
trouni / README.md
Last active August 27, 2021 05:29
Use a credential file on Heroku

How to use a credential file on Heroku (json, yml, etc.)

  1. Add an initializer file to write the credentials file
# config/initializers/json_credentials.rb
filepath = './credentials.json'
File.write(filepath, ENV['YOUR_JSON_CREDENTIALS']) unless File.exists?(filepath)
@trouni
trouni / rails_partials_tips.md
Last active November 20, 2023 13:17
Rails Partials Tips

Rails Partials Pro Tips

Best practices to keep you Rails views tidy and your components smart.

Pro Tip #1 💡 When should you use a partial?

Think in terms of component. Can those few lines be reused somewhere else in your application? If the answer is yes, it should be in a partial.

@trouni
trouni / SynthVoice.js
Last active March 9, 2021 09:15
Simple implementation of a speechSynthesis object
function SynthVoice(options = {}) {
this.synth = window.speechSynthesis;
this.utterance = new SpeechSynthesisUtterance()
// Default options
this.options = { voiceURI: "Google US English" }
Object.assign(this.options, options)
this.getVoices = () => {
// Need to wait until getVoices() actually returns some results
return new Promise(resolve => {