Skip to content

Instantly share code, notes, and snippets.

View hiasinho's full-sized avatar

Mathias Maisberger hiasinho

View GitHub Profile
@hiasinho
hiasinho / regex_dec_w_unit.rb
Created January 9, 2012 15:50
Regex for decimal with unit
matchdata = "121,32 Std.".match(/([\d]+[\,|\.]?\d{0,2})+\s?(\w.*)?/)
matchdata[1] # => "121,32"
matchdata[2] # => "Std."
matchdata[0] # => "121,32 Std."
Ctrl+A
@hiasinho
hiasinho / factory_girl_strategy_find_or_create.rb
Last active May 27, 2020 18:31
FactoryGirl strategy for adding find & find_or_create
## http://stackoverflow.com/questions/7145256
module FactoryGirl
module Strategy
class Find
def association(runner)
runner.run
end
def result(evaluation)
build_class(evaluation).where(get_overrides(evaluation)).first
module FactoryGirlHelper
def find_or_create(*args)
name = args.shift
clazz = nil
# convert from underscores String to camelcase Class
if name.is_a? Hash
name = name.first[0]
clazz = name.first[1].to_s.camelize.constantize
@hiasinho
hiasinho / backbone.react.coffee
Last active August 29, 2015 14:14
React mixin for integrating Backbone
Backbone.React = {} unless Backbone.React
Backbone.React.Base = {} unless Backbone.React.Base
###
Backbone React Base Mixin
=========================
Usage example:
--------------
@hiasinho
hiasinho / instructions.md
Last active January 26, 2017 13:48
DigitalOcean, Dokku, Rails, PostgreSQL
@hiasinho
hiasinho / modernie.md
Last active September 1, 2021 22:23
Internet Explorer on Vagrant

The Modern.ie Virtual Machine Images – VMs used for testing several versions of IE – are now also available as vagrant boxes. Here’s the list:

var hello = "Hello Hias!";
console.log(hello);
@hiasinho
hiasinho / Todos.js
Last active June 3, 2016 06:06
Reducer Adapters
import React, {PropTypes} from 'react';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import TodoActions as actions from '../actions';
import TodoList from '../components/TodoList';
// This is for POJO
import { query } from '../utils/helpersPojo'
// Uncomment this is for Immutable.js
@hiasinho
hiasinho / vim-cheatsheet.md
Last active November 19, 2016 13:16
VIM Cheatsheet

VIM Cheat Sheet

Cursor movement

Key Description
h move cursor left
j move cursor down