Skip to content

Instantly share code, notes, and snippets.

View kitlangton's full-sized avatar
🤠

Kit Langton kitlangton

🤠
View GitHub Profile
class Photo < ActiveRecord::Base
has_many :profiles
has_attached_file :photo, :styles => { :medium => "300x300", :large => "500x500", :thumb => "100x100" }, :s3_host_name => 's3-us-west-2.amazonaws.com'
validates_attachment_content_type :photo, :content_type => /\Aimage\/.*\Z/
validates_with AttachmentSizeValidator, attributes: :photo, less_than: 5.megabytes
validates_attachment_presence :photo, presence: true
<style>
.dumb {
color: chartreuse;
background-color: red;
}
</style>
<!DOCTYPE html>
<html lang="en">
import Devise from 'ember-simple-auth/authenticators/devise';
export default Devise.extend({
tokenAttributeName: 'authentication_token'
});
import Ember from 'ember';
const { inject: { service }, RSVP } = Ember;
export default Ember.Service.extend({
session: service(),
store: service(),
loadCurrentUser() {
return new RSVP.Promise((resolve, reject) => {
import Ember from 'ember';
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';
const { service } = Ember.inject;
export default Ember.Route.extend({
sessionAccount: service('session-account'),
beforeModel() {
return this._loadCurrentUser();
import Ember from 'ember';
export default Ember.Controller.extend({
session: Ember.inject.service('session'),
sessionAccount: Ember.inject.service(),
actions: {
authenticate() {
let {email, password} = this.getProperties('email', 'password');
this.get('session').authenticate('authenticator:devise', email, password)
@kitlangton
kitlangton / Lib.hs
Last active September 19, 2018 20:11
Amazon Scraper
{-# LANGUAGE OverloadedStrings #-}
module Lib where
import Text.HTML.Scalpel
import Data.Maybe (fromMaybe)
import Data.Char
import Control.Applicative
import Text.Read (readMaybe)
@kitlangton
kitlangton / vim.py
Last active February 14, 2020 06:29
Talon vim grammar
from talon import Context, actions
import webbrowser
ctx = Context("vim")
ctx.lists["self.commands"] = {
"change": "c",
"delete": "d",
"yank": "y",
"copy": "y",
@kitlangton
kitlangton / animator.scala
Created April 19, 2020 22:09
Laminaranimator
package animator
import com.raquo.airstream.eventstream.EventStream
import com.raquo.airstream.signal.{Signal, Var}
import magnolia.{CaseClass, Magnolia}
import org.scalajs.dom
import scala.language.experimental.macros
object Time {
@kitlangton
kitlangton / idea-live-templates.xml
Last active July 16, 2023 21:33
IDEA Live Templates
<template name="fr" value="for {&#10; $VARIABLE$ &lt;- $VALUE$&#10;} yield $FINISH$" description="for comprehension" toReformat="false" toShortenFQNames="true">
<variable name="VALUE" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="VARIABLE" expression="" defaultValue="&quot;x&quot;" alwaysStopAt="true" />
<variable name="FINISH" expression="" defaultValue="VARIABLE" alwaysStopAt="true" />
<context>
<option name="SCALA" value="true" />
</context>
</template>
<template name="FR" value="for {&#10; $VARIABLE$ &lt;- $SELECTION$&#10;} yield $FINISH$" description="for comprehension" toReformat="false" toShortenFQNames="true">
<variable name="VARIABLE" expression="" defaultValue="&quot;x&quot;" alwaysStopAt="true" />