Skip to content

Instantly share code, notes, and snippets.

View renews's full-sized avatar
😀

Renê Schneider renews

😀
View GitHub Profile
@renews
renews / cookbook.md
Last active August 29, 2015 14:14 — forked from thebyrd/cookbook.md

#Cookbook

Redis

If you don’t want to spend time setting up redis yourself, just use thebyrd/[email protected]

$ bowery add cache
$ bowery connect
$ bowery ssh cache
root@17e65aa587e8:/# apt-get install -y gcc
root@17e65aa587e8:/# wget http://download.redis.io/releases/redis-2.8.6.tar.gz
# add the email package
meteor add email
@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];
@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 / 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 / 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();
});
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 / 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
@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)