This file contains 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
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") |
This file contains 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
debug_str = "params: #{params}, current_employee: #{employee.try(:id)}" | |
Appsignal.send_exception(e, debug_text: debug_str) |
This file contains 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
perl -pi -w -e 's/ and/ &&/g;' *.rb |
This file contains 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
# Destructive! Use carefully. | |
# merged branches | |
((`git branch --merge master`).strip!.split(' ') - ['master', 'release']).map{ |b| `git branch -D "#{b}"; git push origin :"#{b}"` } | |
# All local branches | |
((`git branch`).strip!.split(' ') - ['master', 'release', 'development']).map{ |b| `git branch -D "#{b}"; git push origin :"#{b}"` } |
This file contains 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
# ~/.bashrc: executed by bash(1) for non-login shells. | |
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) | |
# for examples | |
# If not running interactively, don't do anything | |
case $- in | |
*i*) ;; | |
*) return;; | |
esac |
This file contains 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
irb(main):012:0> Date.today | |
=> Thu, 09 Jul 2015 | |
irb(main):013:0> Date.tomorrow | |
=> Sat, 11 Jul 2015 | |
irb(main):014:0> Date.today.tomorrow | |
=> Fri, 10 Jul 2015 |
This file contains 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
// run this in your browser's console | |
setInterval(function(){window.scrollBy(0, 1), 4000 }) | |
// not well tested |
This file contains 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
(defun no-of-ele (lst) | |
"Return the no. of elements in a list" | |
(if (endp lst) | |
0 | |
(progn (+ 1 (no-of-ele (rest lst)))) | |
) | |
) | |
;; CL-USER> (no-of-ele '(1 2 3)) | |
;; 3 |
This file contains 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
(defun elek (lst n) | |
(if (= n 0) | |
(progn | |
(car lst)) | |
(elek (rest lst) (- n 1)) | |
) | |
) | |
;; CL-USER> (elek '(1 2 3 4) 2) | |
;; 3 |
This file contains 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
(defun last-of-list (l) | |
"Returns last element of a list" | |
(nth (- (list-length l) 1) l)) |
NewerOlder