Skip to content

Instantly share code, notes, and snippets.

View danielfriis's full-sized avatar

Daniel Friis danielfriis

View GitHub Profile
@danielfriis
danielfriis / _Table Helper for Rails
Last active April 12, 2024 10:14
Table helper for Rails
Table Helper for Rails
@danielfriis
danielfriis / autosave_controller.js
Last active April 17, 2023 06:59
Autosave using Stimulus and Rails 7
// app/javascript/controllers/autosave_controller.js
import { Controller } from "@hotwired/stimulus";
import debounce from "lodash.debounce";
// Connects to data-controller="autosave"
export default class extends Controller {
connect() {
this.form = this.element.closest("form");
this.formData = new FormData(this.form);
.service('Shots', ['$http', 'Auth', function($http, Auth) {
var accessToken = Auth.getAccessToken();
return {
all: function(list, page) {
return $http.get('http://api.dribbble.com/v1/shots/?list=' + list + "&access_token=" + accessToken + "&page=" + page + "&per_page=10);
},
isLiked: function(shotId) {
return $http.get('https://api.dribbble.com/v1/shots/' + shotId + '/like?access_token=' + accessToken).success(function (data) {
if(shot_id == data.id) {
return true