Skip to content

Instantly share code, notes, and snippets.

Avatar

Filippos Vasilakis vasilakisfil

View GitHub Profile
@havenwood
havenwood / arity_range.rb
Last active Aug 29, 2015
Ask a method, lambda or proc for the range of arguments it can be called with from minimum to maximum.
View arity_range.rb
module ArityRange
def arity_range
args = parameters.map &:first
req = args.count :req
opt = args.include?(:rest) ? Float::INFINITY : args.count(:opt)
keyreq = args.count :keyreq
keyopt = args.include?(:keyrest) ? Float::INFINITY : args.count(:key)
View Springworks-puzzle.md
echo "=oQM2kzM4MjN0kDN3QzLlNnLztmcvd3ZulmcwN3LvoDc0RHa" | rev | base64 --decode -i
http://springworks.se/474946383961

And a PUT request to that resource responds with the next step of the challenge.

@d-mart
d-mart / domain_validator.rb
Created Oct 4, 2012 — forked from rietta/domain_validator.rb
Rails 3 Bare Domain Validator
View domain_validator.rb
#
# Domain Validator by Frank Rietta
# (C) 2012 Rietta Inc. All Rights Reserved.
# Licensed under terms of the BSD License.
#
# To use in a validation, add something like this to your model:
#
# validates :name, :domain => true
#
class DomainValidator < ActiveModel::EachValidator
@Samsinite
Samsinite / array.js
Created Jan 26, 2015
Array transform for ember-data
View array.js
import Ember from 'ember';
import DS from 'ember-data';
export default DS.Transform.extend({
serialize: function(deserialized) {
return !!deserialized ? deserialized.toArray() : null;
},
deserialize: function(serialized) {
return Ember.A(serialized);
@dklisiaris
dklisiaris / rails-boilerplate.md
Last active Aug 18, 2017
A manual setup for a typical rails 4.x. app with bootstrap layout, devise authentication, rspec testing framework with capybara and git version control.
View rails-boilerplate.md

Setup a new project and database.

Create a new rails app named app_name without Test::Unit and with mysql database:

rails new app_name -T -d mysql

or an app without Test::Unit and with postgresql database:

rails new app_name -T -d postgresql

or without Test::Unit and with the default sqlite:

View radio-button-component.js
// {{ radio-button name='dish' value='spam' groupValue=selectedDish selectedAction='testAction' }} Spam
// {{ radio-button name='dish' value='eggs' groupValue=selectedDish }} Eggs
//
/*
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'input',
type: 'radio',
attributeBindings: [ 'checked', 'name', 'type', 'value' ],
@jeckel
jeckel / APIDays2018-Presentations.md
Last active Dec 12, 2018
APIDays 2018 Presentations and Resources
View APIDays2018-Presentations.md

Twitter LinkedIn

APIDays Logo

APIDays 2018 - Presentations and Resources

Here is a collection of links to presentations and other resources shared during the last #APIDays2018 in Paris.

If you find some mistakes, or have any links to add to this list, feel free to add some comments, or contact me on Twitter or LinkedIn

@vasilakisfil
vasilakisfil / run.sh
Last active Jun 11, 2020
New linux machine setup
View run.sh
#install essential stuff
sudo apt-get install build-essential autoconf locate
sudo apt-get install git guake zsh curl vim vim-gtk3 postgresql-client \
postgresql postgresql-contrib redis golang direnv tmux bat ripgrep fzf
curl -L http://install.ohmyz.sh | sh
chsh -s /bin/zsh
zsh
#edit pg_hba.conf
@alex-zige
alex-zige / gist:5795358
Last active Feb 27, 2021
Rails Rspec API Testing Notes
View gist:5795358

Rails Rspec APIs Testing Notes

Folders Structure

  spec
  |--- apis #do not put into controllers folder. 
        |--- your_api_test_spec.rb  
  |--- controllers
  |--- models
  |--- factories
 |--- views
@jingoro
jingoro / gist:3015664
Created Jun 29, 2012
Mongoid Callback Sequence
View gist:3015664
require 'rubygems'
require 'bundler/setup'
require 'mongoid'
Mongoid.configure do |config|
config.master = Mongo::Connection.new('localhost', 27017, :logger => nil).db('mongoid-test')
end
class A
include Mongoid::Document