Skip to content

Instantly share code, notes, and snippets.

View thesunwave's full-sized avatar
🏠
Working from home

Artur Malev thesunwave

🏠
Working from home
View GitHub Profile
Ws42::Application.routes.draw do
# Root route
root to: "public#index"
#Routes
match "/about", to: "public#about", via: "get"
#Auth routes
devise_for :users
class PublicController < ApplicationController
before_filter :authenticate_user!, :except => [:about]
def index
@users = User.all
end
def about
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
def after_sign_in_path_for(resource)
root_path
end
def after_sign_out_path_for(resource_or_scope)
@thesunwave
thesunwave / 0_reuse_code.js
Last active August 29, 2015 14:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

Deploy Rails 4 app with Dokku on DigitalOcean

Install dokku

First create a Ubuntu 13.04 x64 droplet on DigitalOcean Control Panel

Then ssh with root account, run this in termianl:

$ wget -qO- https://raw.github.com/progrium/dokku/master/bootstrap.sh | sudo bash
/**
* cbpAnimatedHeader.js v1.0.0
* http://www.codrops.com
*
* Licensed under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*
* Copyright 2013, Codrops
* http://www.codrops.com
*/
@thesunwave
thesunwave / urlable.rb
Last active August 29, 2015 14:21 — forked from kugaevsky/urlable.rb
require 'active_support/concern'
require 'addressable/uri'
require 'simpleidn'
require 'faraday'
# Normalize and validate URLs
module Urlable
extend ActiveSupport::Concern
included do
@thesunwave
thesunwave / gist:e4148c7e9f7ffd14e645
Last active August 29, 2015 14:26 — forked from dalethedeveloper/gist:1503252
Mobile Device Detection via User Agent RegEx

#Mobile Device Detection via User Agent RegEx

Yes, it is nearly 2012 and this exercise has been done to death in every imaginable language. For my own purposes I needed to get the majority of non-desktop devices on to a trimmed down, mobile optimized version of a site. I decided to try and chase down an up-to-date RegEx of the simplest thing that could possibly work.

I arrived at my current solution after analyzing 12 months of traffic over 30+ US based entertainment properties (5.8M+ visitors) from Jan - Dec 2011.

The numbers solidified my thoughts on the irrelevancy of including browsers/OSes such as Nokia, Samsung, Maemo, Symbian, Ipaq, Avant, Zino, Bolt, Iris, etc. The brass tacks of the matter is that you certainly could support these obscure beasts, but are you really going to test your site on them? Heck, could you even find one?! Unless the folks that pay you are die hard Treo users my guess is "No".

Interestingly enough my research shows that /Mobile/ is more efficient than **/iP(

@thesunwave
thesunwave / SassMeister-input.sass
Created October 12, 2015 12:17
Generated by SassMeister.com.
// ----
// Sass (v3.4.14)
// Compass (v1.0.3)
// ----
@import "compass"
.contest
&__header
&__active
position: relative