Skip to content

Instantly share code, notes, and snippets.

Avatar

Maciek Rząsa mrzasa

  • Toptal
  • Rzeszów
View GitHub Profile
View regex.rb
DATA.read.gsub(/(\s|)+([!?;]+(\s|\z))/, ' \2\3')
__END__
GET /wp-login.php HTTP/1.1 69
GET /show.aspx HTTP/1.1 15
@kml
kml / regexp_breaking_ruby.rb
Last active December 15, 2022 19:44
Regexp breaking Ruby
View regexp_breaking_ruby.rb
# encoding: utf-8
require 'minitest'
require 'minitest/autorun'
describe "regexp" do
let(:regexp) { /(\s*(<p>\s*<\/p>)\s*)+\Z/mi }
it "cleans up trailing empty tag from simple string" do
"X <p> </p> ".gsub(regexp, "").must_equal "X"
@tokenvolt
tokenvolt / simple_form_bootstrap3.rb
Last active January 12, 2022 19:47
Bootstrap 3 simple form initializer
View simple_form_bootstrap3.rb
inputs = %w[
CollectionSelectInput
DateTimeInput
FileInput
GroupedCollectionSelectInput
NumericInput
PasswordInput
RangeInput
StringInput
TextInput
@andreypronin
andreypronin / custom_plan_zeus_rspec.rb
Created April 6, 2013 15:18
Custom_plan.rb and zeus.json for smooth RSpec experience with Zeus.
View custom_plan_zeus_rspec.rb
require 'zeus/rails'
class CustomPlan < Zeus::Rails
def spec(argv=ARGV)
# disable autorun in case the user left it in spec_helper.rb
RSpec::Core::Runner.disable_autorun!
exit RSpec::Core::Runner.run(argv)
end
end
View jruby_breaker.rb
=begin
$ uname -a
Linux jboss-updater2 3.2.21-nkt #1 SMP Wed Aug 1 20:23:57 CEST 2012 x86_64 GNU/Linux
$ java -version
java version "1.7.0_03"
OpenJDK Runtime Environment (IcedTea7 2.1.1pre) (7~u3-2.1.1~pre1-2)
OpenJDK 64-Bit Server VM (build 22.0-b10, mixed mode)
$ jruby --version
@ruanltbg
ruanltbg / LAMP.md
Last active August 1, 2016 13:59
Set up of a Rails + Nginx + Unicorn OR LAMP in Ubuntu
View LAMP.md

Apache

$ sudo apt-get update
$ sudo apt-get install apache2
# activate mod_rewrite
$ sudo a2enmod rewrite
#restart
$ sudo service apache2 restart

Mysql

@prognostikos
prognostikos / app.js
Created September 11, 2012 13:45
AngularJS & Rails
View app.js
/**
* Angular needs to send the Rails CSRF token with each post request.
*
* Here we get the token from the meta tags (make sure <%= csrf_meta_tags %>
* is present in your layout.)
*/
angular.module('myapp',[]).
// configure our http requests to include the Rails CSRF token
config(["$httpProvider", function(p) {
var m = document.getElementsByTagName('meta');
@thinkerbot
thinkerbot / gem_env.sh
Created November 8, 2010 18:28
Illustrates GEM_HOME vs GEM_PATH
View gem_env.sh
# Two ENV variables control the 'gem' command:
#
# GEM_HOME: the single path to a gem dir where gems are installed
# GEM_PATH: a standard PATH to gem dirs where gems are found
#
# A gem directory is a directory that holds gems. The 'gem' command will lay
# out and utilize the following structure:
#
# bin # installed bin scripts
# cache # .gem files ex: cache/gem_name.gem