Skip to content

Instantly share code, notes, and snippets.

View forsaken1's full-sized avatar
💭
Elixir one love

Alex Krylov forsaken1

💭
Elixir one love
View GitHub Profile
@abury
abury / routes.js
Last active February 21, 2018 03:41
PlainRoute example with require auth for React-redux
// We only need to import the modules necessary for initial render
import CoreLayout from '../layouts/CoreLayout/CoreLayout';
import Home from './Home';
import LoginRoute from './Login';
import SignupRoute from './Signup';
import DashboardRoute from './Secure/Dashboard';
import LeadsRoute from './Secure/Leads';
import NotFound from './NotFound';
/* Note: Instead of using JSX, we recommend using react-router
@gEndelf
gEndelf / react.md
Last active October 16, 2017 14:16
react docs:
@sebboh
sebboh / gist:f1dfe4f096746c45f3e9ea06a09743a0
Last active February 27, 2024 17:10 — forked from masonforest/gist:4048732
Installing a Gem on Heroku from a Private GitHub Repo

Installing a Gem on Heroku from a Private GitHub Repo

Sometimes you want to use a gem on Heroku that is in a private repository on GitHub.

Using git over http you can authenticate to GitHub using basic authentication. However, we don't want to embed usernames and passwords in Gemfiles. Instead, we can use authentication tokens.

This method does not add your OAuth token to Gemfile.lock. It uses bundle config to store your credentials, and allows you to configure Heroku to use environment variables when deploying.

  1. Generate an OAuth token from GitHub
@Ravenstine
Ravenstine / reactor.cr
Created September 8, 2015 05:29
A very simple event loop written in Crystal. (crystal-lang.org)
module Reactor
class Task
property :block
def initialize(timestamp=Time.now, milliseconds=0, &block : Loop ->)
@block = block
@timestamp = timestamp.epoch_ms
@milliseconds = milliseconds
end
def run reactor
require 'nokogumbo'
require 'uri'
def print_parents visited, path
parent = path
while parent = visited[parent]
puts "parent: %s" % URI.unescape(parent)
end
end
@dnlserrano
dnlserrano / api_controller.rb
Last active January 19, 2021 09:56
Custom Authentication Controllers
class ApiController < ApplicationController
# define which model will act as token authenticatable
acts_as_token_authentication_handler_for Login
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :null_session
respond_to :json
skip_before_filter :verify_authenticity_token, if: :json_request?
@gonzalo-bulnes
gonzalo-bulnes / sessions_controller.rb
Last active August 24, 2017 09:41
A SimpleTokenAuthentication-compatible JSON version of Devise::SessionsController. (UPDATE: For a discussion about this gist and a better version of it, please see https://github.com/gonzalo-bulnes/simple_token_authentication/issues/48#issuecomment-42133939)
# app/controllers/sessions_controller.rb
class SessionsController < Devise::SessionsController
# This controller provides a JSON version of the Devise::SessionsController and
# is compatible with the use of SimpleTokenAuthentication.
# See https://github.com/gonzalo-bulnes/simple_token_authentication/issues/27
def create
# Fetch params
@tinynumbers
tinynumbers / active_admin.rb
Last active August 15, 2024 16:11
ActiveAdmin controller extension to persist resource index filters between requests.
# this stuff goes in config/initializers/active_admin.rb
ActiveAdmin.setup do |config|
# ...
# put these lines in the "Controller Filters" section of the ActiveAdmin.setup block
# These two are defined in ActiveAdmin::FilterSaver::Controller, which is loaded below.
config.before_filter :restore_search_filters
@magnetikonline
magnetikonline / README.md
Last active March 14, 2024 22:48
IE 7/8/9/10/11 Virtual machines from Microsoft - Linux w/VirtualBox installation notes.
@romikoops
romikoops / acceptance_helper.rb
Created April 13, 2012 16:57
Rspec configuration and acceptance test for quick integration with Social Networks
# -*- encoding : utf-8 -*-
require 'spec_helper'
OmniAuth.config.test_mode = true
OmniAuth.config.add_mock(:facebook, {:uid => '123545',
:info => { :email => '[email protected]',
:first_name => "First",
:last_name => "Last"}
})
OmniAuth.config.add_mock(:vkontakte, {:uid => '123545',