Skip to content

Instantly share code, notes, and snippets.

View BadAllOff's full-sized avatar
I'm open to new opportunities

BadAllOff BadAllOff

I'm open to new opportunities
View GitHub Profile
@BadAllOff
BadAllOff / .gitignore RAILS
Last active September 15, 2015 02:31
A Sample Rails .gitignore file
# See http://help.github.com/ignore-files/ for more about ignoring files.
# Based on https://gist.github.com/chrishough/6488118
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile ~/.gitignore_global
###############################################################################################
# Ignore specific config files
###############################################################################################
.bundle/*
@BadAllOff
BadAllOff / application.html.erb
Last active August 16, 2018 17:55 — forked from suryart/application.html.erb
Rails 4 flash messages WITH GLYPHICONS using Twitter Bootstrap(bootstrap-sass: https://github.com/thomas-mcdonald/bootstrap-sass). An improved version of https://gist.github.com/roberto/3344628
// layout file
<body>
<div class="container">
<%= flash_messages %>
<%= yield %>
</div><!-- /container -->
</body>
@BadAllOff
BadAllOff / rubocop_pre_commit_hook
Created January 21, 2016 12:27 — forked from palkan/rubocop_pre_commit_hook
Rubocop pre-commit hook
#!/usr/bin/env ruby
ADDED_OR_MODIFIED = /^\s*(A|AM|M)/.freeze
changed_files = `git status --porcelain`.split(/\n/)
unstaged_files = `git ls-files -m`.split(/\n/)
changed_files = changed_files.select { |f| f =~ ADDED_OR_MODIFIED }
changed_files = changed_files.map { |f| f.split(" ")[1] }
@BadAllOff
BadAllOff / capybara cheat sheet
Created January 26, 2016 13:22 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@BadAllOff
BadAllOff / gist:b203a304f3dfe50377f7
Created February 1, 2016 12:24 — forked from stuart11n/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@BadAllOff
BadAllOff / js-courses.md
Created March 24, 2016 15:58 — forked from alexbaumgertner/js-courses.md
JavaScript courses as on March 2016
@BadAllOff
BadAllOff / omniauth_macros.rb
Created July 14, 2016 20:49 — forked from kinopyo/omniauth_macros.rb
Integration test with Omniauth. This example is using twitter, and assume you've installed rspec and capybara. Official document is here: https://github.com/intridea/omniauth/wiki/Integration-Testing
# in spec/support/omniauth_macros.rb
module OmniauthMacros
def mock_auth_hash
# The mock_auth configuration allows you to set per-provider (or default)
# authentication hashes to return during integration testing.
OmniAuth.config.mock_auth[:twitter] = {
'provider' => 'twitter',
'uid' => '123545',
'user_info' => {
'name' => 'mockuser',
@BadAllOff
BadAllOff / README.md
Created July 27, 2016 08:34 — forked from jxson/README.md
README.md template

Synopsis

At the top of the file there should be a short introduction and/ or overview that explains what the project is. This description should match descriptions added for package managers (Gemspec, package.json, etc.)

Code Example

Show what the library does as concisely as possible, developers should be able to figure out how your project solves their problem by looking at the code example. Make sure the API you are showing off is obvious, and that your code is short and concise.

Motivation

@BadAllOff
BadAllOff / production.rb
Created August 19, 2016 09:49 — forked from vkurennov/production.rb
Пример конфига unicorn
# paths
app_path = "/home/deployer/qna"
working_directory "#{app_path}/current"
pid "#{app_path}/current/tmp/pids/unicorn.pid"
# listen
listen "/tmp/unicorn.qna.sock", :backlog => 64
# logging
stderr_path "log/unicorn.stderr.log"
@BadAllOff
BadAllOff / monit.rc
Last active August 20, 2016 01:16 — forked from vkurennov/monit.rc
Пример конфига для запуска процессов через monit
### Nginx ###
check process nginx with pidfile /opt/nginx/logs/nginx.pid
start program = "/etc/init.d/nginx start"
stop program = "/etc/init.d/nginx stop"
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if memory usage > 80% for 5 cycles then restart
if failed host 127.0.0.1 port 80 protocol http
then restart
if 3 restarts within 5 cycles then timeout