Skip to content

Instantly share code, notes, and snippets.

@MaximeHeckel
MaximeHeckel / Example.js
Last active April 6, 2022 22:11
Example of App replacing Redux with Context and Hooks
// reducer.js
export const initialState = {
data: null
};
const reducer = (state, action) => {
const reduced = { ...state };
switch (action.type) {
case "FETCH_DATA":
return {
@RailsCod3rFuture
RailsCod3rFuture / routes.rb
Last active June 11, 2021 08:40
Failing User Profile Controller, Routes and Partial Form
Rails.application.routes.draw do
devise_for :admins
devise_for :users
namespace :api do
scope :v1 do
mount_devise_token_auth_for 'User', at: 'user_auth'
end
end
@dpawluk
dpawluk / do_the_things_v1.js
Created December 6, 2016 20:41
Get PDF from URL, create Object URL, then download/open in a browser window
(function() {
return {
events: {
'app.activated':'init'
},
init: function() {
var self = this;
@brunofacca
brunofacca / rails_api_token_auth_with_tiddle.md
Last active October 13, 2023 00:55
Rails API token authentication with Tiddle gem in apps with web views

This gist attempts to explain how to implement token authentication in Rails, using Devise and Tiddle. Tiddle was designed to provide token auth for API-only Rails apps. However, the following instructions will enable you to use it in Rails apps which have both APIs and web views.

##Why Tiddle?

Devise is the obvious choice for authentication on Rails. However, token authentication was

// http://leafletjs.com/examples/quick-start-example.html in TypeScript
/// <reference path="leaflet.d.ts" />
var map = new L.Map("map");
map.setView(new L.LatLng(51.505, -0.09), 13);
var layer =new L.TileLayer("http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png", { maxZoom: 18, attribution: "attribution test" })
layer.addTo(map);
// add marker
var marker = new L.Marker(new L.LatLng(51.5, -0.09));
marker.addTo(map).bindPopup("<b>Hello world!</b><br />I am a popup.").openPopup();
@agraves
agraves / pages_controller_test.rb
Created October 9, 2012 21:13
Minitest controller test with clearance
require 'test_helper'
describe PagesController do
before{ sign_in }
subject{ PagesController.new }
%w{some_page another_page}.each do |page|
describe "rendering the #{page} page" do
it 'should render successfully' do