Skip to content

Instantly share code, notes, and snippets.

View scmx's full-sized avatar

Albert Arvidsson scmx

View GitHub Profile
@scmx
scmx / gist:10716766
Created April 15, 2014 09:18
#osx #systempreferences #slow #system.log #error
Apr 15 08:47:45 albert-mbp kernel[0]: virtual bool IOHIDEventSystemUserClient::initWithTask(task_t, void *, UInt32): Client task not privileged to open IOHIDSystem for mapping memory (e00002c1)
Apr 15 08:47:45 albert-mbp.local System Preferences[529]: void __IOHIDEventQueueuRegister(): Unable to open IOHIDSystem (e00002bd)
@scmx
scmx / gist:3b05cd80e530af0efe0a
Last active August 29, 2015 14:01
#ubuntu #14.04 #new #server #ruby #rails #nginx #unicorn
# Create a new server
# Always choose a LTS (Long Term Stable) ubuntu release,
# such as 12.04, 14.04 etc
apt-get update
# Pick and choose what you need
apt-get install tmux
apt-get install git-core
@scmx
scmx / bootstrap_form_builder.rb
Created May 23, 2014 11:03
BootstrapFormBuilder #rails #bootstrap3 #has-error, based on http://stackoverflow.com/a/22183501
#
# Bootstrap 3 integration for rails form_for
#
class BootstrapFormBuilder < ActionView::Helpers::FormBuilder
# Creates a .form-group which adds .has-error automatically
# Usage:
# <%= f.form_group :attribute_name %>
# Result:
# <div class="form-group has-error" />
# http://stackoverflow.com/a/22183501
@scmx
scmx / .profile
Created May 26, 2014 13:54
#åäö #ubuntu #14.04 #tmux Append this to ~/.profile for all users
export LANG=sv_SE.UTF-8
export LANGUAGE=sv:en
export LC_CTYPE=sv_SE.UTF-8
export LC_NUMERIC=sv_SE.UTF-8
export LC_TIME=sv_SE.UTF-8
export LC_COLLATE="sv_SE.UTF-8"
export LC_MONETARY=sv_SE.UTF-8
export LC_MESSAGES="sv_SE.UTF-8"
export LC_PAPER=sv_SE.UTF-8
export LC_NAME=sv_SE.UTF-8
@scmx
scmx / maximum-words-validation.js
Created December 3, 2014 16:56
#angular #validation validate maximum word count textarea
angular.module('maximumWordsValidation', [])
// Counts number of words in field and sets validity if more than max
//
// Usage:
// <input maximum-words-validation="100"/>
// Example:
// <textarea ng-model="myModel.description" maximum-words-validation="100"></textarea>
// <span>{{myModel_description_words_count}} / 100 words</span>
//
// It will also set the {{fieldName}}_word_count variable on parent scope
@scmx
scmx / pbqropen.sh
Last active August 29, 2015 14:11
Turn clipboard content into a QR code #osx #pbpaste #qrencode #pbqropen #clipboard #crcode #shortcut #automator #shell

Add a new automator script, choose type: Service

Choose input: none

Tell it to run a shell script:

# Path to where you saved pbqropen
$HOME/.bin/pbqropen
@scmx
scmx / gist:ada7033fd1ea00c6f80b
Created January 2, 2015 10:18
#fix #åäö #ubuntu

om man är inne på en server där åäö inte fungerar

lägg till i ~/.profile

# Fix åäö
export LANG=sv_SE.UTF-8
export LANGUAGE=sv:en
export LC_CTYPE=sv_SE.UTF-8
export LC_NUMERIC=sv_SE.UTF-8
export LC_TIME=sv_SE.UTF-8
@scmx
scmx / gist:9e11c6a038e155af4f93
Created January 13, 2015 10:35
How a tiny typo in an angular service that got unnoticed, could become a bug several months later

How a tiny typo in an angular service that got unnoticed, could become a bug several months later

# Typo done in august
.factory("Subtask", function($resource) {
-   return $resource("/tasks/:task_id/subtasks/:id", {task_id: "@task_id", id: "@id"});
+   return $resource("tasks/:task_id/subtasks/:id", {task_id: "@task_id", id: "@id"});
  }]);
@scmx
scmx / gist:8761d6a12f63d918b33e
Last active August 27, 2022 23:22
letter opener Super simple alternative #ruby #rails #development #staging #letter_opener #delivery_method

letter_opener_web

# app/controllers/emails_controller.rb
# Could not get gem letter_opener_web to work as intended,
# This is a simple alternative that uses delivery_method :test
class EmailsController < ActionController::Base
  layout nil

  def index
    @deliveries = ActionMailer::Base.deliveries.reverse
@scmx
scmx / gist:8d07e3acb09dd9a092ec
Created January 28, 2015 16:56
#TIL #capybara #save_and_open_page #pry

Today I learned that when using a binding.pry like this inside a Capybara feature test

require "test_helper"

feature "User::CanResetPassword" do
  before do
    visit reset_password_path
  end

 scenario "valid email" do