Skip to content

Instantly share code, notes, and snippets.

View eduardosasso's full-sized avatar

Eduardo Sasso eduardosasso

View GitHub Profile
@eduardosasso
eduardosasso / hotstoks-app-script.js
Created October 21, 2021 03:28
Hotstoks trending stocks app script
function main() {
const data = JSON.parse(fetchData());
sheet().clear({ formatOnly: false, contentsOnly: true });
sheet().clearNotes();
sheet().appendRow(
[
"Symbol",
"Price",
@eduardosasso
eduardosasso / hotstoks.sql
Created October 21, 2021 03:16
Hotstoks trending stocks
SELECT
name,
symbol,
price,
price_change_percent_1d,
price_change_percent_1m,
price_change_percent_3m,
price_change_percent_6m,
price_change_percent_ytd,
moving_avg_50d_percent_diff,
name: Build
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
- cron: '50 12 * * 1-5' # free edition mon-fri 8:50 ET
- cron: '55 12 * * 1-5' # premium morning mon-fri 8:55 ET
version: "2"
options:
verbose: true
syncs:
rails-app-sync:
src: './'
sync_strategy: 'native_osx'
sync_excludes: ['.git/', '*.log']
version: '3'
services:
redis-docker:
image: redis:3
container_name: redis-docker
memcached-docker:
image: memcached:1.5
container_name: memcached-docker
mysql-docker:
container_name: mysql-docker
FROM ruby:2.2
RUN apt-get -y update
RUN apt-get -y install zlib1g-dev libssl-dev libreadline6-dev libyaml-dev gawk autoconf libgdbm-dev libncurses5-dev automake libtool bison libffi-dev openssl links rsync bc
RUN apt-get -y install redis-server memcached default-jre build-essential curl nodejs npm mysql-client libmysqlclient-dev git vim libxml2 libxml2-dev libxslt-dev openssl libcurl4-openssl-dev libmagickcore-dev libmagickwand-dev imagemagick
RUN mkdir -p /app
WORKDIR /app
rails: rails s -p 3000 -b 0.0.0.0
sidekiq: sidekiq -q cache_control -q generic -q data_import
solr: sunspot-solr run --data-directory=./solr4/data --solr-home=./solr4 --max-memory=1512M --port=8982
compass: compass watch
#!/bin/bash
bundle check || bundle install --jobs 20 --retry 5 --system --binstubs="$BUNDLE_BIN"
if [ -f tmp/pids/server.pid ]; then
rm -f tmp/pids/server.pid
fi
bundle exec foreman start -f procfile_docker
@eduardosasso
eduardosasso / schedule.rb
Created October 14, 2014 18:29
Remove jobs from scheduler
i = 0
Sidekiq::ScheduledSet.new.each do |job|
next unless job.klass.match(/WeeklyRecommendationPushWorker/)
p i += 1
count = Sidekiq.redis do |conn|
conn.zremrangebyscore("schedule", job.score, job.score)
end
end
@eduardosasso
eduardosasso / fix_photo_rotation.rb
Created December 18, 2013 19:31
Recut images that have from the original picture different from the width saved in the DB. This happens because of a bug on ImageMagick that was changing width to height and vice versa for a few images and that would make the image appear in landscape on the recuts even though the image is originally landscape. This should be run in the new serv…
cond = "orientation='landscape' and status=1 and place_type != 'User'"
Media.where(cond).find_each do |media|
begin
image = Media.image_from_blob(media.fetch_original)
p "Media #{media.id} has different width: #{image.columns != media.width} - height: #{image.rows != media.height}"
if image.columns != media.width
p "Recuting media: #{media.id}"
media.recut
Rails.cache.delete("place_images_#{media.place_type}_#{media.place_id}_topic")
end