Skip to content

Instantly share code, notes, and snippets.

@mankind
mankind / rails-jsonb-queries
Last active April 17, 2024 12:14
Ruby on Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
@mankind
mankind / rails-elasticbean.txt
Created March 31, 2016 12:39
Deploying a simple Rails application with AWS Elastic Beanstalk
Deploying a simple Rails application with AWS Elastic Beanstalk by Julien SIMON, Principal Technical Evangelist @ Amazon Web Services
18/02/2016
http://www.slideshare.net/JulienSIMON5/deploying-a-simple-rails-application-with-aws-elastic-beanstalk
1. . Create a Git repository with AWS CodeCommit
$ aws codecommit create-repository --repository-name blog --region us-east-1 --repository-description "ElasticBeanstalk demo"
$ git clone ssh://git-codecommit.us- east-1.amazonaws.com/v1/repos/blog
2. Create a new Rails application
@mankind
mankind / bing.html
Last active November 11, 2023 17:54
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Landing Page</title>
<link rel="stylesheet" href="https://unpkg.com/tailwindcss@^3.0.2/dist/tailwind.min.css">
<script src="https://cdn.tailwindcss.com"></script>
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
0.00632 18.00 2.310 0 0.5380 6.5750 65.20 4.0900 1 296.0 15.30 396.90 4.98 24.00
0.02731 0.00 7.070 0 0.4690 6.4210 78.90 4.9671 2 242.0 17.80 396.90 9.14 21.60
0.02729 0.00 7.070 0 0.4690 7.1850 61.10 4.9671 2 242.0 17.80 392.83 4.03 34.70
0.03237 0.00 2.180 0 0.4580 6.9980 45.80 6.0622 3 222.0 18.70 394.63 2.94 33.40
0.06905 0.00 2.180 0 0.4580 7.1470 54.20 6.0622 3 222.0 18.70 396.90 5.33 36.20
0.02985 0.00 2.180 0 0.4580 6.4300 58.70 6.0622 3 222.0 18.70 394.12 5.21 28.70
0.08829 12.50 7.870 0 0.5240 6.0120 66.60 5.5605 5 311.0 15.20 395.60 12.43 22.90
0.14455 12.50 7.870 0 0.5240 6.1720 96.10 5.9505 5 311.0 15.20 396.90 19.15 27.10
0.21124 12.50 7.870 0 0.5240 5.6310 100.00 6.0821 5 311.0 15.20 386.63 29.93 16.50
0.17004 12.50 7.870 0 0.5240 6.0040 85.90 6.5921 5 311.0 15.20 386.71 17.10 18.90
@mankind
mankind / react-rich-editor
Last active November 16, 2022 23:43
react rich editors
https://editorjs.io/
https://remirror.io/
https://kuy.io/blog/posts/modern-front-end-magic-with-rails-7-a-visual-editor-for-markdown-part-1
https://www.rippling.com/blog/building-editors-in-react-applications
from slatejs to tiptap
https://www.ashbyhq.com/blog/engineering/tiptap-part-1
### slatejs
https://jkrsp.com/slate-js-placeholder-per-line/
https://dev.to/devcer/notion-like-placeholders-for-every-line-slatejs-4hoh
@mankind
mankind / django--rails.md
Last active October 24, 2022 07:30
mapping python & django to ruby & rails
django vs rails

django views map to rais controllers

polls/views.py¶

from django.http import HttpResponse

from .models import Question

data-scientist
https://jaidevd.com/posts/code-readability-process/
## django tips
https://testdriven.io/blog/django-vs-flask/
https://github.com/django-extensions/django-extensions
# wsgi
https://www.b-list.org/weblog/2018/feb/22/teenage-django/
https://www.b-list.org/weblog/2009/aug/10/wsgi/
@mankind
mankind / gist:b686f12691d0ed9649fa25141c6934d0
Created July 26, 2021 16:32
Setting up Hyku Addons Account

Setting up Hyku Addons from scratch

Deleting existing system

If already exists and you want to start fresh DANGER: This will kill it all including data

docker-compose down
docker-compose system prune
@mankind
mankind / create dropdown ie hyku authority or controlled vocabulary
Last active July 7, 2020 09:30
Add multipart metadata fields to samvera active_fedora models
Your next task is to turn the audience field into a dropdown and the dropdown options are 'particpant', 'spectator', 'graduate', 'apprentice'
See http://samvera.github.io/customize-metadata-controlled-vocabulary.html
1. Create a yaml file conatining vocabularies ie dropdown names in config/authorities with thesame name as your field. So if your field is funder, you will have
config/authorities/funder.yml eg https://github.com/ubiquitypress/hyku/blob/test/config/authorities/funder.yml
http://samvera.github.io/customize-metadata-controlled-vocabulary.html#create-a-vocabulary
In that file, add the values you want in your dropdown following the format above.
2. Create a service to load the dropdown names or vocabularies in app/services/
@mankind
mankind / crossref_response
Last active June 29, 2020 14:52
auto-populate forms using datacite and crossref api
module Ubiquity
class CrossrefResponse
attr_reader :error, :attributes
def initialize(response_hash = nil)
@error = error
@attributes = response_hash['message']
end
def title
attributes['title']