https://stackoverflow.com/questions/46687645/upgrade-postgresql-from-9-6-to-10-0-on-ubuntu-16-10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sass-convert -F scss -T sass application_styles.css.scss application_styles.css.sass | |
| # If you want convert folder recursively | |
| sass-convert -R scss_folder -F scss -T sass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| start_id = Product.maximum(:id) + 1 | |
| table = :products | |
| ApplicationRecord.connection.execute("ALTER SEQUENCE #{table}_id_seq RESTART WITH #{start_id}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Fibonacci | |
| class << self | |
| def sum_of_even_upto(max) | |
| upto(max).inject(0) do |sum, item| | |
| item.even? ? sum + item : sum | |
| end | |
| end | |
| def upto(max) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [1] (pry) main: 0> add = -> (a, b) { a + b } | |
| => #<Proc:0x007ffde11d72c0@(pry):1 (lambda)> | |
| # Call proc with two arguments | |
| [2] (pry) main: 0> add.(1, 2) | |
| => 3 | |
| # Call proc with one argument | |
| [3] (pry) main: 0> add.(1) | |
| ArgumentError: wrong number of arguments (1 for 2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT count(*), DATE_TRUNC( 'month', created_at ) created_date | |
| FROM businesses | |
| GROUP BY created_date |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace :db do | |
| desc "Backup DB as separate schema" | |
| task :backup_to_schema, [:created_at] => :environment do |t, args| | |
| schema = 'copy' | |
| created_at = args.created_at || 2.years.ago | |
| ApplicationRecord.connection.execute( | |
| "DROP SCHEMA #{schema} CASCADE; | |
| CREATE SCHEMA copy" | |
| ) | |
| ActiveRecord::Base.connection.execute "SET search_path TO public, #{schema}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Human | |
| def initialize(name) | |
| @name = name | |
| end | |
| def read_book(book, page_number) | |
| page = book.open_page(page_number) | |
| read(page) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| !function(){function t(){function n(t,e){s=s.concat(RFB.messages.keyEvent(t,e))}var o=e.shift(),s=[],i=o.charCodeAt(),c=-1!=='!@#$%^&*()_+{}:"<>?~|'.indexOf(o),r=XK_Shift_L;c&&n(r,1),n(i,1),n(i,0),c&&n(r,0),rfb._sock.send(s),e.length>0&&setTimeout(t,10)}var e=prompt("Enter text to be sent to console").split("");t()}(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fetch('http://code.jquery.com/jquery-latest.min.js').then(response => response.text()).then(text => { eval(text); console.log($) }) |