Skip to content

Instantly share code, notes, and snippets.

View foxweb's full-sized avatar
🏠
Working from home

Aleksey Kurepin foxweb

🏠
Working from home
View GitHub Profile
a = [0, 1, 2, 3, 4, 5]
# example 1
def reverse(array)
array.each_with_index do |val, index|
break if index >= array.count / 2
temp = array[index]
array[index], array[-index-1] = array[-index-1], temp
end
@foxweb
foxweb / cleandir.sh
Created January 21, 2022 23:35
Removing extra files (hidden files from macOS) and files/dirs permissions fix.
#!/bin/sh
sudo chown -R foxweb:foxweb ./*
find . -name "*" -type d -print0 | xargs -0 /bin/chmod 755
find . -name "*" -type f -print0 | xargs -0 /bin/chmod 644
find . -name ".DS_Store" -type f -print0 | xargs -0 /bin/rm
find . -name "._*" -type f -print0 | xargs -0 /bin/rm
find . -name ".AppleDouble" -type d -print0 | xargs -0 /bin/rm -rf
@foxweb
foxweb / gps_parser.rb
Last active June 19, 2020 14:04
Extract GPS-coordinates from JPEG with Ruby and imagemagick
class GpsParser
def initialize(file_path)
@file_path = file_path
end
def converted_gps
return if raw_exif_data.empty?
{
latitude: float_gps(:GPSLatitude, :GPSLatitudeRef),
require 'benchmark'
n = 100_000
abc = ('A'..'Z').to_a
Benchmark.bm do |x|
x.report { n.times { rand(65..90).chr } }
x.report { n.times { rand('A'.ord..'Z'.ord).chr } }
x.report { n.times { ('A'..'Z').to_a.sample } }
x.report { n.times { abc.sample } }
Style/FrozenStringLiteralComment:
EnforcedStyle: never
Layout/AccessModifierIndentation:
EnforcedStyle: outdent
Layout/EmptyLinesAroundAccessModifier:
Enabled: false
Layout/ExtraSpacing:
swagger: '2.0'
info:
version: '1.0'
title: Nightingale API
description: Перед вами документация по Nightingale API (система управления контентом). Пока API без версионирования. Звёздочками отмечены обязательные поля. В двойных фигурных {{скобках}} указаны переменные, заданные в environment.
host: example.com
basePath: /
schemes:
- http
consumes:
2017-07-10 13:54:32 +0300: Rack app error: #<Faraday::ConnectionFailed>
/usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/net-http-persistent-2.9.4/lib/net/http/persistent.rb:641:in `rescue in connection_for'
/usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/net-http-persistent-2.9.4/lib/net/http/persistent.rb:589:in `connection_for'
/usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/net-http-persistent-2.9.4/lib/net/http/persistent.rb:994:in `request'
/usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/faraday-0.9.2/lib/faraday/adapter/net_http_persistent.rb:25:in `perform_request'
/usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/faraday-0.9.2/lib/faraday/adapter/net_http.rb:40:in `block in call'
/usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/faraday-0.9.2/lib/faraday/adapter/net_http_persistent.rb:21:in `with_net_http_connection'
/usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/faraday-0.9.2/lib/faraday/adapter/net_http.rb:32:in
0x9f9263e8a207de5f4a102cfcf02ee87e463bcc4d
Retrieving cheshire-5.7.0.jar from https://clojars.org/repo/
Retrieving instaparse-1.4.5.jar from https://clojars.org/repo/
Retrieving jackson-dataformat-cbor-2.8.6.jar from https://repo1.maven.org/maven2/
Retrieving jackson-core-2.8.6.jar from https://repo1.maven.org/maven2/
Retrieving jackson-dataformat-smile-2.8.6.jar from https://repo1.maven.org/maven2/
clojure.lang.ExceptionInfo:
data: {:file "parser.clj", :line 85}
java.lang.NullPointerException:
clojure.core/file-seq/fn core.clj: 4772
clojure.core/tree-seq/walk/fn core.clj: 4762
rake aborted!
ActiveAdmin::DatabaseHitDuringLoad: Your file, app/models/subscription_type.rb (line 22), caused a database error while Active Admin was loading. This is most common when your database is missing or doesn't have the latest migrations applied. To prevent this error, move the code to a place where it will only be run when a page is rendered. One solution can be, to wrap the query in a Proc.Original error message: PG::UndefinedTable: ERROR: relation "subscription_types" does not exist
LINE 5: WHERE a.attrelid = '"subscription_types"'::re...
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"subscription_types"'::regclass
AND a.attnum > 0 AND NOT a.attis