Skip to content

Instantly share code, notes, and snippets.

View scmx's full-sized avatar

Albert Arvidsson scmx

View GitHub Profile
@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: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
@scmx
scmx / gist:0985b2d8a85314a10d26
Created March 4, 2015 11:36
Is the internet on fire? OSX Notification

Have you seen the excellent https://istheinternetonfire.com/ website?

They provide a nice dns txt api that I decided to use the give myself an OSX notification whenever they update.

img

Save the following to a file somewhere in your $PATH. I chose .bin/istheinternetonfire

#!/usr/bin/env bash
@scmx
scmx / gist:cf471c13333712c789d9
Last active August 29, 2015 14:18
Migrate old paperclip folders into the newer id_partition structure #rails #paperclip #id_partition #migrate

The version below is specifically tailored to handle a model named Item where the attachment is called image.

#!/usr/bin/env ruby

require "fileutils"

if File.directory? "public/system/items/images"
  puts "Nothing to do, you've already done this"
  exit 0
@scmx
scmx / Gemfile
Last active August 29, 2015 14:19
Roundcube merge two separate intersecting databases #roundcube #mysql #contacts #merge #ruby #activerecord
source "https://rubygems.org"
gem 'mysql2'
gem 'activerecord'
gem 'safe_attributes'
@scmx
scmx / pomodoro.sh
Last active December 31, 2015 21:08
Minimalistic pomodoro for OSX with Skype integration. EDIT: Here is an alternative: https://gist.github.com/scmx/8234441
#!/usr/bin/env bash
usage() {
cat <<EOD
Usage:
pomodoro [minutes] Start a pomodoro, defaults to 25 minutes
EOD
}
case "$1" in
@scmx
scmx / gist:b07361dd3071669320a7
Last active January 7, 2016 18:03
Adding a new ruby version to a server with rbenv
ssh deploy@some-server
# Upgrade ruby-build (So it knows about the new ruby version and so can fetch it for us)
cd ~/.rbenv/plugins/ruby-build
git pull
# Grab a coffee while downloading ruby
rbenv install 2.2.4
# Make sure bundle command is available
@scmx
scmx / immutable-delete.js
Last active March 28, 2017 10:13
While writing a redux reducer I ran into the issue that I wanted to remove a property from an object without mutating it. Here's how I solved it. tl;dr Just use http://devdocs.io/lodash/index#omit #redux #reducers #immutability
import test from 'ava'
import deepFreeze from 'deep-freeze'
import omit from 'lodash/omit'
test('normal delete will mutate the object', t => {
const obj = { a: 1, b: 2 }
deepFreeze(obj)
t.throws(() => delete obj.a)
})
@scmx
scmx / ghpr.md
Last active July 1, 2017 10:56
Bash function for checking out a github pull request branch #git #github #pull-request #bash

Are you having trouble checking out someone's pullrequest from a terminal?

Example usage

git clone git@github.com:example/example.git
ghpr someuser:somebranch # Copy this from the PR

It does these things

  • Adds someuser as a git remote