Skip to content

Instantly share code, notes, and snippets.

View iwan's full-sized avatar

Iwan Buetti iwan

  • Milano, Italy
View GitHub Profile
@vparihar01
vparihar01 / printingJavascriptObject.js
Created June 25, 2013 13:23
for printing down the javascript [object Object] value.This get all properties values of a Javascript Object (without knowing the keys).
for(var key in objects) {
var value = objects[key];
}
Object.values = function (obj) {
var vals = [];
for( var key in obj ) {
if ( obj.hasOwnProperty(key) ) {
vals.push(obj[key]);
}
@tomas-stefano
tomas-stefano / Capybara.md
Last active April 25, 2024 16:44
Capybara cheatsheet

Capybara Actions

# Anchor
click_link 'Save'

# Button
click_button 'awesome'

# Both above
@didats
didats / nationality.html
Created December 28, 2013 00:00
Nationality List in HTML Dropdown
<select name="nationality">
<option value="">-- select one --</option>
<option value="afghan">Afghan</option>
<option value="albanian">Albanian</option>
<option value="algerian">Algerian</option>
<option value="american">American</option>
<option value="andorran">Andorran</option>
<option value="angolan">Angolan</option>
<option value="antiguans">Antiguans</option>
<option value="argentinean">Argentinean</option>
@magicznyleszek
magicznyleszek / jekyll-and-liquid.md
Last active January 12, 2024 03:46
Jekyll & Liquid Cheatsheet

Jekyll & Liquid Cheatsheet

A list of the most common functionalities in Jekyll (Liquid). You can use Jekyll with GitHub Pages, just make sure you are using the proper version.

Running

Running a local server for testing purposes:

@iwan
iwan / route.rb
Last active August 29, 2015 13:59 — forked from vparihar01/route.rb
# NOTE below gems are only for development purpose can be removed and commented out as per requirement
group :development do
gem 'rails-erd','1.0.0'
gem 'hirb','0.7.0'
gem 'railroady'
gem 'itslog','0.6.1'
gem 'quiet_assets'
gem 'sextant' # now included in Rails 4.0
end
@moertel
moertel / suppress_ruby_output.rb
Last active March 21, 2024 08:54
Temporarily suppress STDOUT and STDERR (ruby)
# Temporarily redirects STDOUT and STDERR to /dev/null
# but does print exceptions should there occur any.
# Call as:
# suppress_output { puts 'never printed' }
#
def suppress_output
original_stderr = $stderr.clone
original_stdout = $stdout.clone
$stderr.reopen(File.new('/dev/null', 'w'))
$stdout.reopen(File.new('/dev/null', 'w'))
require 'net/http'
def download_net_http(urls, thread_count)
queue = Queue.new
urls.map { |url| queue << url }
threads = thread_count.times.map do
Thread.new do
Net::HTTP.start('our-s3-bucket.s3.amazonaws.com', 80) do |http|
while !queue.empty? && url = queue.pop
@mgamini
mgamini / Elixir Email Validation
Last active March 27, 2023 17:42
Elixir Email Validation
defmodule EmailValidator do
# ensure that the email looks valid
def validate_email(email) when is_binary(email) do
case Regex.run(~r/^[\w.!#$%&’*+\-\/=?\^`{|}~]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$/i, email) do
nil ->
{:error, "Invalid email"}
[email] ->
try do
Regex.run(~r/(\w+)@([\w.]+)/, email) |> validate_email
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
describe "GET #index" do
#describe "POST #create" do
#describe "GET #show" do
#describe "PATCH #update" do (or PUT #update)
#describe "DELETE #destroy" do
#describe "GET #new" do
@hofmannsven
hofmannsven / README.md
Last active November 8, 2023 22:49
SCSS Cheatsheet