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
class ApplicationController < ActionController::Base | |
after_filter :allow_iframe | |
protect_from_forgery with: :exception | |
private | |
def current_user | |
User.first | |
#@current_user ||= User.find(session[:user_id]) if session[:user_id] | |
end |
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
var http = axios.create() | |
http.interceptors.request.use(function(request) { | |
let csrfToken = sessionStorage.csrf | |
request.headers.post['X-CSRF-Token'] = csrfToken | |
request.headers.patch['X-CSRF-Token'] = csrfToken | |
request.headers.delete['X-CSRF-Token'] = csrfToken | |
} |
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
@authentication_cookie = response.env[:response_headers]["set-cookie"] | |
response = conn.get do |req| | |
req.headers ['cookie'] = @authentication_cookie | |
req.url, params | |
end |
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
# $ rails c | |
# > require "#{Rails.root}/test.rb" | |
# > TestTb.new.test1; TestTb.new.test2 | |
# * Results: 27252 records processed in: 56 sec (within Transaction), 107 sec (without Transaction) | |
class TestTb | |
TRANSACTION_SCOPE = -> (func) { Book.transaction { func.call } } | |
WHERE_QUERY = -> { { autor_id: @value == 0 ? 1 : 0 } } | |
def initialize; @percent_count = @percents = @count = 0 end |
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
<!-- HTML generated using hilite.me --><div style="background: #000000; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><table><tr><td><pre style="margin: 0; line-height: 125%"> 1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 |
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
git archive -o update.zip HEAD $(git diff --name-only HEAD~5) |
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
At `heroku run bash` session: | |
wget -O - https://gist.githubusercontent.com/vitalyp/b7ee6db012c33709f7f8de5e58dd05b5/raw/846999eb9896ae4b3280422561cb1d510cefdb53/heroku_mc.sh | bash |
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
#!/bin/bash | |
# Create file: | |
# cat > heroku_mc.sh <<- "EOF" | |
# this file contents | |
# EOF | |
mkdir -p /tmp | |
McDIR="/tmp/mc";McBinDIR="$McDIR/bin";mkdir -p $McDIR;cd $McDIR;TmpDIR="/temp_deb";mkdir -p $McDIR/$TmpDIR;cd $McDIR/$TmpDIR;wget http://security.ubuntu.com/ubuntu/pool/universe/m/mc/mc_4.8.1-2ubuntu1_amd64.deb;ar -x mc_4.8.1-2ubuntu1_amd64.deb;tar -xvf data.tar.gz; | |
mv usr/* $McDIR;mkdir $McDIR/etc;mv ./etc/mc/* $McDIR/etc;cd $McDIR;rm -rf $TmpDIR; |
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
# with comments | |
def get_random_bytes count | |
random = `dd if=/dev/urandom | head -c #{count}` | |
puts "random data is:\n#{random}\n\r-----length is: #{random.length}" | |
random | |
end | |
def clip_encoded_with data_str, encoding | |
encoded = data_str.encode(encoding, invalid: :replace, undef: :replace, replace: '') |
NewerOlder