Skip to content

Instantly share code, notes, and snippets.

🥑
Eating avocado

Dmitry Polushkin dmitry

🥑
Eating avocado
Block or report user

Report or block dmitry

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dmitry
dmitry / timelapse.sh
Last active Jan 4, 2018
ffmpeg timelapse scripts for sony as300
View timelapse.sh
for FILE in `ls *.JPG`; do \
mogrify -resize 1920x -write resized/$FILE $FILE; \
done
for FILE in `ls *.JPG`; do \
mogrify -resize 1920x1080^ -gravity center -crop 1920x1080+0+0 +repage -write resized/$FILE $FILE; \
done
for i in $(ls *.JPG); do exiv2 -r '%Y%m%d.%H%M%S' rename $i; done
@dmitry
dmitry / sort_items_extension.rb
Last active Jun 15, 2017
Sort Items fast with mysql and postgres queries on acts_as_list position column
View sort_items_extension.rb
module SortItemsExtension
def sort_items(ids)
unless ids.is_a?(Array)
raise ArgumentError, "ids isn't an array"
end
ids.map!(&:to_i)
old_ids = proxy_association.ids_reader
ids = ids - (ids - old_ids)
View benchmark_sql.rb
(0..24).to_a.map do Thread.new do 0.upto(20000) do |i| ActiveRecord::Base.connection.execute("SELECT * FROM properties WHERE #{i}=#{i} LIMIT 1").to_a end end end.map(&:join)
View animation_name_hack.css
body {
animation-duration: 0.001s;
}
@media screen and (min-width: 769px) {
body {
animation-name: media-table;
}
}
@media screen and (max-width: 768px) {
body {
View capistrano_test.rb
namespace :test do
run 'echo #{bundle_cmd}'
end
View elasticsearch code.js
var value = 1;
var c = days.length;
for (var i = 0; i < c; i++) {
var v = _source.minimum_stays[days[i]];
if (v && value < v) {
value = v;
}
}
if (value == 1) {
value = _source.minimum_nights
@dmitry
dmitry / date.md
Last active Oct 2, 2016
elasticsearch date historgram
View date.md
curl -XGET 'http://localhost:42001/bookings/booking/_search?&pretty=true' -d '{
  "aggs": {
    "test": {
      "filter": {
        "terms": {
          "status": ["accepted"]
        }
      },
      "aggs": {
@dmitry
dmitry / elasticsearch_logger.js
Created Aug 24, 2016
Elasticsearch script logger (javascript)
View elasticsearch_logger.js
var logger=org.elasticsearch.common.logging.ESLoggerFactory.getLogger('myscript');
logger.info(this);
You can’t perform that action at this time.