Skip to content

Instantly share code, notes, and snippets.

Avatar

Linus Marton Linuus

View GitHub Profile
View location.ex
defimpl Ecto.DataType, for: Map do
def cast(%{lat: lat, long: long}, Geo.Point), do: cast(%{"lat" => lat, "long" => long}, Geo.Point)
def cast(%{"lat" => lat, "long" => long}, Geo.Point) do
{:ok, %Geo.Point{coordinates: {long, lat}, srid: 4326}}
end
def cast(arg1, arg2) do
:error
end
def dump(%Geo.Point{} = point), do: {:ok, point}
@Linuus
Linuus / test_case.rb
Last active Oct 9, 2017
Touch not working on destroy
View test_case.rb
# frozen_string_literal: true
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
@Linuus
Linuus / pyqt5.rb
Created Mar 21, 2016
Pyqt5 homebrew formulae which installs QT5.5 instead of 5.6. You must tap homebrew-versions first.
View pyqt5.rb
class Pyqt5 < Formula
desc "Python bindings for v5 of Qt"
homepage "https://www.riverbankcomputing.com/software/pyqt/download5"
url "https://downloads.sourceforge.net/project/pyqt/PyQt5/PyQt-5.5.1/PyQt-gpl-5.5.1.tar.gz"
sha256 "0a70ef94fbffcf674b0dde024aae2a2a7a3f5a8c42806109ff7df2c941bd8386"
revision 1
bottle do
sha256 "9372001ae57afee47b5326439e9ecdac778ff18279515f45d4a0b8209247ab89" => :el_capitan
sha256 "6c66da7a5f6716181e0fcb35970b65dacd8bd1bc023ac9e0ab790c47921f74e3" => :yosemite
View new.js
// cards/new.js
import Ember from 'ember';
export default Ember.ObjectController.extend({
needs: ['board'],
board: Ember.computed.alias('controllers.board'),
actions: {
createCard: function() {
var board = this.get('board');
board.get('cards').pushObject(this.get('model')).save().then(function() {
@Linuus
Linuus / vimrc
Created Jun 5, 2013
Failing vimrc from tmux
View vimrc
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
@Linuus
Linuus / gist:5130247
Created Mar 10, 2013
Pygments output
View gist:5130247
<div class="highlight"><pre> <span class="n">def</span> <span class="n">index</span>
<span class="err">@</span><span class="n">cars</span> <span class="o">=</span> <span class="n">Car</span><span class="p">.</span><span class="n">all</span>
<span class="n">respond_to</span> <span class="k">do</span> <span class="o">|</span><span class="n">format</span><span class="o">|</span>
<span class="n">format</span><span class="p">.</span><span class="n">html</span> <span class="err">#</span> <span class="n">index</span><span class="p">.</span><span class="n">html</span><span class="p">.</span><span class="n">erb</span>
<span class="n">format</span><span class="p">.</span><span class="n">json</span> <span class="p">{</span> <span class="n">render</span> <span class="n">json</span><span class="o">:</span> <span class="err">@</span><span class="n">cars</span> <span class="p">}</span>
<span class="n">end</span>
<span class="n">end</span>
<span class="err">#</span> <span class="n">GET</span> <
@Linuus
Linuus / README.md
Created Sep 19, 2012 — forked from agnoster/README.md
My ZSH Theme
View README.md

agnoster.zsh-theme

A ZSH theme optimized for people who use:

  • Solarized
  • Git
  • Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)

Compatibility

@Linuus
Linuus / gist:3641331
Created Sep 5, 2012
active admin error
View gist:3641331
2012-09-05T17:56:18+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_view/renderer/template_renderer.rb:45:in `render_template'
2012-09-05T17:56:18+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_view/renderer/renderer.rb:17:in `render'
2012-09-05T17:56:18+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/abstract_controller/rendering.rb:110:in `_render_template'
2012-09-05T17:56:18+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
2012-09-05T17:56:18+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/abstract_controller/rendering.rb:103:in `render_to_body'
2012-09-05T17:56:18+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/abstract_controller/rendering.rb:88:in `render'
2012-09-05T17:56:18+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_controller/metal/renderers.rb:28:in `render
View minitest_helper.rb
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require "minitest/autorun"
require "minitest/rails"
# Uncomment if you want Capybara in accceptance/integration tests
require "minitest/rails/capybara"
# Uncomment if you want awesome colorful output