Skip to content

Instantly share code, notes, and snippets.

View leemour's full-sized avatar

Viacheslav Ptsarev leemour

View GitHub Profile
@leemour
leemour / console.rb
Last active August 29, 2015 14:02 — forked from marcamillion/console.rb
Rails 4 cache_counter for has_and_belongs_to_many relationship
## I imagine this could be done in the migration, but it was giving me problems so I moved it to the model
## and just did it on the command line
> Tag.reset_questions_count
@leemour
leemour / Rakefile
Created April 1, 2014 12:48 — forked from jeffreyiacono/Rakefile
rake task for precompiling assets using sprockets within a sinatra app + view helpers
require 'rubygems'
require 'bundler'
Bundler.require
require './application'
namespace :assets do
desc 'compile assets'
task :compile => [:compile_js, :compile_css] do
end
#!/usr/bin/env bash
# Simple move this file into your Rails `script` folder. Also make sure you `chmod +x puma.sh`.
# Please modify the CONSTANT variables to fit your configurations.
# The script will start with config set by $PUMA_CONFIG_FILE by default
PUMA_CONFIG_FILE=config/puma.rb
PUMA_PID_FILE=tmp/pids/puma.pid
PUMA_SOCKET=tmp/sockets/puma.sock
HTML
=====
<script type='text/javascript'>
window.jQuery || document.write('<script src="js/jquery-1.7.1.js">\x3C/script>')
</script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.0.6/modernizr.min.js' type='text/javascript'></script>
<script type='text/javascript'>
window.Modernizr || document.write('<script src="js/modernizr-2.0.6.js">\x3C/script>')
</script>
@leemour
leemour / form_control.rb
Last active December 27, 2015 03:48 — forked from tanraya/gist:7248683
Form control Simple form bootstrap
%w[
CollectionSelectInput
DateTimeInput
GroupedCollectionSelectInput
NumericInput
PasswordInput
RangeInput
StringInput
TextInput
].each do |input_type|
# A formtastic input which incorporates carrierwave uploader functionality.
#
# Intelligently adds the cache field, displays and links to the current
# value if there is one, adds a class to the wrapper when replacing an
# existing value, allows removing an existing value with the checkbox
# taking into account validation requirements.
#
# There are several options:
#
# * Toggle the replacement field with `replaceable: true/false`.
# Guide
# Configure the essential configurations below and do the following:
#
# Repository Creation:
# cap deploy:repository:create
# git add .
# git commit -am "initial commit"
# git push origin master
#
# Initial Deployment:
// borrowed from https://github.com/samflores
Prism.languages.ruby = {
'comment': /#[^\r\n]*(\r?\n|$)/g,
'string': /("|')(\\?.)*?\1/g,
'regex': {
pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/g,
lookbehind: true
},
'keyword': /\b(alias|and|BEGIN|begin|break|case|class|def|define_method|defined|do|each|else|elsif|END|end|ensure|false|for|if|in|module|new|next|nil|not|or|raise|redo|rescue|retry|return|self|super|then|throw|true|undef|unless|until|when|while|yield)\b/g,
'builtin': /\b(Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Stat|File|Fixnum|Fload|Hash|Integer|IO|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|String|Struct|TMS|Symbol|ThreadGroup|Thread|Time|TrueClass)\b/,
@leemour
leemour / RubyRVM.sublime-build
Created September 6, 2013 15:41 — forked from pmarreck/Ruby.sublime-build
Build Ruby with RVM in Sublime Text 3
# Get Sublime to use your rvm ruby... Change your ~/Library/Application Support/Sublime Text 2/Packages/Ruby/Ruby.sublime-build to this, replacing YOURUSERNAME:
{
"cmd": [
"bundle", "exec", "/Users/YOURUSERNAME/.rvm/bin/rvm-auto-ruby", "$file"
],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.ruby"
}
@leemour
leemour / structure.html
Created August 21, 2013 09:50 — forked from anonymous/structure.html
Responsive Sass
<h2>A thumbnail grid with <a href="https://github.com/Team-Sass/Singularity">Singularity</a> and <a href="https://github.com/lolmaus/breakpoint-slicer">Breakpoint Slicer</a></h2>
<p>Play with the Page pane width to see the responsive magic!</p>
<div class=grid-item>
<div class=thumbnail>
<div class=thumbnail-content>
Thumbnail
</div>
</div>
</div>