Skip to content

Instantly share code, notes, and snippets.

@tomasgregor
tomasgregor / start_rails_project.ts
Last active September 10, 2015 10:42
bash command to open rails application environment
start() {
cd ~/development/railsapps/$1
osascript -e "tell application \"Terminal\"" \
-e "do script \"clear;
bin/rails server\" in front window" \
-e "tell application \"System Events\" to keystroke \"t\" using {command down}" \
-e "do script \"cd ~/development/railsapps/$1;
mate .;
clear\" in front window" \
@tomasgregor
tomasgregor / index.html
Last active August 29, 2015 14:22 — forked from anonymous/index.html
JS Factory Constructor Experiment
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
adsfadsfsdfa
<script id="jsbin-javascript">
require 'spec_helper'
describe CampaignsController do
let(:user){ create(:admin_user) }
before(:each) do
sign_in user
end
describe "GET #index" do
@tomasgregor
tomasgregor / get_element_id.js
Created January 22, 2014 16:22
Parse element's id
var id = ($this.attr("id").match(/\d+$/));
@tomasgregor
tomasgregor / turbolinks_ready.js
Created December 12, 2013 14:38
Simple way how to handle document.ready with Turbolinks
@tomasgregor
tomasgregor / http_authentication.rb
Created October 23, 2013 11:13
HTTP authentication
def authenticate
authenticate_or_request_with_http_basic do |username, password|
username == "username" && password == "password"
end
end
@tomasgregor
tomasgregor / submit_on_form_complete_focusout.js
Created May 31, 2013 14:19
SUBMIT ON FORM COMPLETE FOCUSOUT JS + jQuery trick which submits the form on focusout event in any of form's input fields but only in a case if the focus hasn't moved to another input field of the same form
$('.container').on('focusout', '.form', function() { // binds function to all forms in a specified container
var elem = $(this);
setTimeout(function() {
if( elem.find(':focus').length == 0 ) { // submits form only if there's no focus in any of the form input fields
elem.submit();
}
}, 200); // timeout of 200 ms to give browser time to register whether focus moved to another input in the same form