Skip to content

Instantly share code, notes, and snippets.

View aypn0s's full-sized avatar

Elias Papadamos aypn0s

View GitHub Profile
@aypn0s
aypn0s / gist:45c345545f575ef09a0acc0a8ea9225a
Created June 3, 2020 08:10
terminate postgresql sessions on database
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'db_name'
AND pid <> pg_backend_pid();
Nokogiri install fix
---------------------
-- --use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2
Mysql2 install fix
---------------------
gem install mysql2 -v '0.4.10' --source 'https://rubygems.org/' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
libv8
---------------------
@aypn0s
aypn0s / gist:8ff9386e0aeca6a112faaba61afe2528
Created May 2, 2018 10:33
Change postgresql id sequence
select * from users_id_seq;
alter sequence users_id_seq restart with 1000;
Truncate:
truncate bad_users restart identity;
{
"caret_extra_width": 1,
"drag_text": false,
"font_face": "Menlo",
"font_size": 12,
"hot_exit": false,
"ignored_packages":
[
"Vintage"
],
mysql -uroot -p[pass] -e 'show databases' -N | grep -Ev 'information_schema|mysql' | while read dbname; do mysqldump -uroot -p[pass] "$dbname" > "$dbname".sql; done
@aypn0s
aypn0s / Close div when click outside
Created June 26, 2015 08:43
Close div when click outside
$(document).mouseup (e) ->
if !$('#theID').is(e.target) && $('#theID').has(e.target).length == 0
$('#theID').hide()
@aypn0s
aypn0s / Carrierwave delete folders after destroy
Created January 14, 2015 13:11
Carrierwave delete folders after destroy
after :remove, :delete_empty_dirs
def delete_empty_dirs
path = File.expand_path(store_dir, root)
Dir.rmdir(path)
rescue
true
end
@aypn0s
aypn0s / Friendly_id with babosa
Created December 17, 2014 12:59
Friendly_id with babosa
extend FriendlyId
friendly_id :title, use: :slugged
def normalize_friendly_id(input)
input.to_s.to_slug.normalize(transliterations: :greek).to_s
end
def should_generate_new_friendly_id?
title_changed?
end
@aypn0s
aypn0s / Nginx conf
Last active August 29, 2015 14:10
Nginx conf
passenger_max_pool_size 60;
passenger_pool_idle_time 10;
passenger_max_request_queue_size 500;
client_body_buffer_size 10K;
client_header_buffer_size 1k;
client_max_body_size 8m;
large_client_header_buffers 4 16k;
client_body_timeout 12;
@aypn0s
aypn0s / Devise store session
Last active August 29, 2015 14:02
Devise store session
# Application controller
before_action :store_location
def store_location
if request.path != '/users/sign_in' &&
request.path != '/users/sign_up' &&
request.path != '/users/password/new' &&
request.path != '/users/password/edit' &&
!request.xhr? && !request.post? && !request.put?