Skip to content

Instantly share code, notes, and snippets.

View capripot's full-sized avatar
💭

Ronan capripot

💭
View GitHub Profile
@dkandalov
dkandalov / long_running_exec.rb
Last active June 2, 2023 14:37
Ruby method to execute and continuously print output of long-running shell command
#!/usr/bin/ruby
require "open4"
def shell_exec(command)
puts("> " + command + "\n")
pid, stdin, stdout, stderr = Open4::popen4(command)
while Process::waitpid(pid, Process::WNOHANG).nil? do
stdout.each_line { |line| puts line }
stderr.each_line { |line| puts line }
sleep(1)
@tomas-stefano
tomas-stefano / Capybara.md
Last active July 2, 2025 01:57
Capybara cheatsheet

Capybara Actions

# Anchor
click_link 'Save'

# Button
click_button 'awesome'

# Both above
@mifix
mifix / Setup and forget Apache Host and PHP configuration
Last active February 22, 2016 03:23
Setup and forget Apache Host and PHP configuration. (VirtualDocumentRoot and php-fpm)
Prerequisites
=============
$ apt-get install apache2-mpm-worker libapache2-mod-fastcgi php5-fpm php5 php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
$ a2enmod actions fastcgi alias rewrite vhost_alias
$ sudo service apache2 reload
@madrobby
madrobby / date.rb
Created February 15, 2013 17:37
`Date.parse` with some extra leeway to handle user input errors. Handles things like `2013-02-31` (parses it as `2013-02-29`) and handles things in general like users would expect.
module Freckle
module Date
class << self
def parse(string)
raw = string.to_s.strip
return nil if raw.empty?
begin
# reverse order if we encounter "European" formatting
<!doctype html>
<!-- http://taylor.fausak.me/2015/01/27/ios-8-web-apps/ -->
<html>
<head>
<title>iOS 8 web app</title>
<!-- CONFIGURATION -->
@them0nk
them0nk / rspec_rails_cheetsheet.rb
Created March 23, 2012 03:39
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)