Skip to content

Instantly share code, notes, and snippets.

View renews's full-sized avatar
😀

Renê Schneider renews

😀
View GitHub Profile
@renews
renews / Remove Inutils from generator
Created August 13, 2013 23:32
Remove helper, assets e coisas de testes.
config.generators do |generators|
generators.helper = false
generators.assets = false
generators.test_framework :rspec, :view_specs => false, :controller_specs => false,
:helper_specs => false, :routing_specs => false, :fixture => true
end
@renews
renews / combobox change when ready
Created August 19, 2013 18:36
Execute the CHANGE function on a combobox when the document get READY.
$(document).ready(function(event) {
$('#countrylist').change(function(e){
// put code here
}).change();
});
@renews
renews / Mysql import via command line
Last active December 30, 2015 04:59
Mysql import via command line
mysql -u user -p -h localhost database < file.sql
@renews
renews / httpresponse.rb
Created January 15, 2014 12:28
Webrick => httpresponse.rb correction so it ill not spam Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
line 205: if chunked? || @header['content-length'] || @status == 304 || @status == 204 || HTTPStatus.info?(@status)
@renews
renews / random_string
Created July 17, 2014 20:18
Generate random strings.
(0...8).map { (65 + rand(26)).chr }.join
I spend too much time golfing.
(0...50).map { ('a'..'z').to_a[rand(26)] }.join
For lots of good WTFBBQ factor.
And a last one that's even more confusing, but more flexible and wastes less cycles:
o = [('a'..'z'), ('A'..'Z')].map { |i| i.to_a }.flatten
string = (0...50).map { o[rand(o.length)] }.join
METEOR CORE:
Anywhere: Meteor.isClient
Anywhere: Meteor.isServer
Anywhere: Meteor.startup(func)
Anywhere: Meteor.absoluteUrl([path], [options])
Anywhere: Meteor.settings
Anywhere: Meteor.release
@renews
renews / ajax_loading_bindings.js
Last active August 29, 2015 14:04
Global Bindings for showing loading on ajax
$(document).ajaxStart(function() {
$("#loading").show();
});
$(document).ajaxStop(function() {
$("#loading").hide();
});
@renews
renews / activerecord_union.rb
Created August 18, 2014 20:59
Ability to use union on activerecord relations. Put: include ActiveRecord::UnionScope in the model.
module ActiveRecord
module UnionScope
def union_scope(*scopes)
id_column = "#{table_name}.id"
if (sub_query = scopes.reject { |sc| sc.count == 0 }.map { |s| s.select(id_column).to_sql }.join(' UNION ')).present?
where "#{id_column} IN (#{sub_query})"
else
none
end
@renews
renews / email_validation
Created August 19, 2014 18:47
Email validation format REGEX
[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)\b
@renews
renews / gup.js
Created November 25, 2014 16:42
Get url parameter - js
function gup( name )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];