Skip to content

Instantly share code, notes, and snippets.

View yorzi's full-sized avatar
🏠
Working from home

Andy Wang yorzi

🏠
Working from home
  • Xi'an, China
  • 22:43 (UTC +08:00)
View GitHub Profile
@yorzi
yorzi / rails_exercise.rb
Last active September 16, 2023 02:29 — forked from rhelsing/rails_exercise.rb
Rails Exercise by Andy Wang
# Background:
# The following code works but I have intentionally introduced issues to make it inefficient.
# UserEvents are created for every interaction a user has in the system. It stores what employer, partner and
# controller they were on. When there were 10 users and only a little bit of traffic, this would run quickly.
# But now with 10,000 users and months of traffic - (millions of user events), this code would be very inefficient.
# Instructions:
# 1. Please make this code more efficient through refactoring so that it can run at a greater scale,
# along with adding some comments to improve the readability.
# 2. Please explain what the variable 'distinct_groups' will contain by the end of the execution and what
@yorzi
yorzi / create-ruby-gem-that-adds-rake-tasks.md
Created May 8, 2023 03:28 — forked from ntamvl/create-ruby-gem-that-adds-rake-tasks.md
How to create a Ruby gem that adds Rake tasks

How to create a Ruby gem that adds Rake tasks

Create a gem

One way to do this is to use bundler to scaffold our gem:

bundler gem my_gem

Add rake tasks to our gem

I prefer to put tasks meant to manage the gem itself in lib/tasks, and tasks the gem is meant to provide to gem users in lib/my_gem/tasks.

@yorzi
yorzi / #ChatGPT Streaming.md
Created May 5, 2023 03:19 — forked from alexrudall/#ChatGPT Streaming.md
ChatGPT streaming with ruby-openai, Rails 7, Hotwire, Turbostream, Sidekiq and Tailwind!

How to add ChatGPT streaming to your Ruby on Rails 7 app!

This guide will walk you through adding a ChatGPT-like messaging stream to your Ruby on Rails 7 app using ruby-openai, Rails 7, Hotwire, Turbostream, Sidekiq and Tailwind. All code included below!

Alt Text

First, add the ruby-openai gem! Needs to be at least version 4. Add Sidekiq too.

@yorzi
yorzi / readme.md
Created August 18, 2021 01:52 — forked from maxivak/readme.md
Integrating Gem/Engine and Main Rails App
@yorzi
yorzi / index.html
Created February 17, 2020 08:52 — forked from tiffany352/index.html
Twitter archive browser
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Twitter Archive Browser</title>
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
<style>
require 'mina/rails'
require 'mina/git'
require 'mina/rvm'
require 'mina/puma'
set :application_name, 'myapp'
set :domain, 'myapp.com'
set :deploy_to, '/home/admin/myapp'
set :repository, 'git@github.com:lnikell/myapp.git'
@yorzi
yorzi / install_postgresql.sh
Created May 22, 2017 06:54 — forked from dstroot/install_postgresql.sh
Install PostgreSQL on Amazon AMI
#!/bin/bash
###############################################
# To use:
# https://raw.github.com/gist/2776351/???
# chmod 777 install_postgresql.sh
# ./install_postgresql.sh
###############################################
echo "*****************************************"
echo " Installing PostgreSQL"
echo "*****************************************"
zh-CN:
admin:
home:
name: "首页"
pagination:
previous: "&laquo; 上一页"
next: "下一页 &raquo;"
truncate: ""
misc:
filter_date_format: "mm/dd/yy" # a combination of 'dd', 'mm' and 'yy' with any delimiter. No other interpolation will be done!
sudo aptitude -y install nginx
cd /etc/nginx/sites-available
sudo rm default
sudo cat > jenkins
upstream app_server {
server 127.0.0.1:8080 fail_timeout=0;
}
server {
listen 80;