Skip to content

Instantly share code, notes, and snippets.

@stopanko
stopanko / serv.rb
Created April 30, 2021 19:48
Employees Counting
<<-SQL
SELECT * FROM departments;
id | name | parent_id | created_at | updated_at
----+-----------+-----------+----------------------------+----------------------------
1 | head1 | | 2021-04-30 17:44:33.98764 | 2021-04-30 17:44:33.98764
2 | head2 | | 2021-04-30 17:44:37.132593 | 2021-04-30 17:44:37.132593
3 | head3 | | 2021-04-30 17:44:40.582593 | 2021-04-30 17:44:40.582593
4 | child_1_1 | 1 | 2021-04-30 17:45:19.021174 | 2021-04-30 17:45:19.021174
5 | child_1_2 | 1 | 2021-04-30 17:45:23.263489 | 2021-04-30 17:45:23.263489
6 | child_2_1 | 2 | 2021-04-30 17:45:34.402745 | 2021-04-30 17:45:34.402745
@stopanko
stopanko / heroku_env_copy.rb
Last active June 24, 2019 11:27 — forked from nabucosound/heroku_env_copy.sh
Script to copy environment variables from an existing heroku app to another one
# https://emirkarsiyakali.com/heroku-copying-environment-variables-from-an-existing-app-to-another-9253929198d9
# Bash script
heroku config -s -a existing-heroku-app > config.txt
cat config.txt | tr '\n' ' ' | xargs heroku config:set -a new-heroku-app
# Ruby Script
#!/usr/bin/env ruby
require 'json'
@stopanko
stopanko / git-commands.sh
Last active March 13, 2019 13:58
Git commands
# Search commits by content in the files
## By default, git grep will look through the files in your working directory.
### This grep commant will output the files in the current directory that contains the gmtime_r inside(Doesnt' matters when this changes was made)
git grep -n gmtime_r
## If you want to know the commint when the changes was introduces you should use git log command
git log -S "Text that was added/deleted in the commit"
## If you want to see the changelog instead pf just commits list use -p option
git log -p -S "Upcoming Travel"
## you can use regular expression
git log -p -G "Upcoming (Travel|Trip)"
@stopanko
stopanko / selector_ready for jQuery 3+
Last active June 25, 2017 10:17
how make script loaded only on specific page
# Selector ready function for jQuery 3+
```javascript
(function ($) {
$.fn.selectorReady = function(fn) {
$($.proxy(function() {
$(this).each(fn);
}, this));
};
})(jQuery);
@stopanko
stopanko / ssl_puma.sh
Created June 3, 2016 11:04 — forked from tadast/ssl_puma.sh
localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@stopanko
stopanko / web-fonts-asset-pipeline.md
Created March 13, 2016 13:32 — forked from anotheruiguy/web-fonts-asset-pipeline.md
Custom Web Fonts and the Rails Asset Pipeline

Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.

Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.

As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.

The recommended way

Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.