Skip to content

Instantly share code, notes, and snippets.

@ursuleacv
ursuleacv / gist:6142488
Created August 2, 2013 19:06
Changing the default rsa key in Git bash for heroku
If you're using msysgit with the OpenSSH tools, you need to either create ~/.ssh/id_rsa, or create a git config in ~/.ssh/config which points to your key.
Here's an example of a Git config for bitbucket that will use the correct username, and a key other than the default key (in case you maintain one key for SSH connections, and another for git accounts).
Host heroku.com
Hostname heroku.com
IdentityFile /C/keys/yourkey.key
Once in git bash, you can run two commands to add your key to your current session's ssh-agent to avoid having to repeatedly type the key's password.
eval `ssh-agent`
@ursuleacv
ursuleacv / gist:6147833
Created August 3, 2013 20:13
How to undo the last Git commit?
git log # to see the last commit id
git reset --hard 5a7404742c85
#or
#git reset --hard HEAD^ # use --hard if you don't care about keeping the changes you made
git commit -am 'restoring the file I removed on accident'
git push origin master --force
@ursuleacv
ursuleacv / gist:6320146
Created August 23, 2013 14:46
Modal pop up window to fit within browser view if resize height
$(function(){
$(window).resize(function(){
// get the screen height and width
var maskHeight = $(window).height();
var maskWidth = $(window).width();
// calculate the values for center alignment
var dialogTop = (maskHeight - $('#dialog-box').height())/2;
var dialogLeft = (maskWidth - $('#dialog-box').width())/2;
@ursuleacv
ursuleacv / gist:6329483
Created August 24, 2013 17:55
Dev vs Stage environment vs Prod Environment
For smaller companies (it's not clear how big yours is), three environments (dev, stage, production) are common. Larger companies will often have a QA environment between dev and stage.
These normally break down as follows:
dev: Working code copy. Changes made by developers are deployed here so integration and features can be tested. This environment is rapidly updated and contains the most recent version of the application.
qa: (Not all companies will have this). Environment for quality assurance; this provides a less frequently changed version of the application which testers can perform checks against. This allows reporting on a common revision so developers know whether particular issues found by testers has already been corrected in the development code.
staging: This is the release candidate, and this environment is normally a mirror of the production environment. The staging area contains the "next" version of the application and is used for final stress testing and client/manager approvals before
@ursuleacv
ursuleacv / gist:6632126
Created September 20, 2013 01:18
Jquery remove an item from dropdown list
<select id="form_type">
<option value="1">c</option>
<option value="2">d</option>
<option value="3">e</option>
</select>
$("#form_type option[value='1']").remove();
@ursuleacv
ursuleacv / gist:6641938
Created September 20, 2013 18:40
Getting all selected checkboxes in an array
<input type="checkbox" value="1" id="all"/>All
<input type="checkbox" value="2" id="m"/>Monday
<input type="checkbox" value="3" id="t"/>Tuesday
<div id="qq"></div> <button id="bb">Click</button>
var selected = new Array();
$(document).ready(function()
@ursuleacv
ursuleacv / gist:6768176
Created September 30, 2013 18:41
Jquery dialog before close effect transfer
beforeClose: function() {
var $this = $(this);
$this
.dialog("widget")
.effect("transfer", {
to: "#form-preview",
className: "ui-effects-transfer"
@ursuleacv
ursuleacv / gist:8730913
Created January 31, 2014 12:11
Two columns
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Пример для css-live.ru</title>
<style type="text/css">
* { margin: 0; padding: 0; }
p { padding: 10px; }
#left { position: absolute; left: 0; top: 0; width: 50%; }
@ursuleacv
ursuleacv / gist:9005588
Created February 14, 2014 17:46
Using Transaction with Active Record in Yii
$model=Post::model();
$transaction=$model->dbConnection->beginTransaction();
try
{
// find and save are two steps which may be intervened by another request
// we therefore use a transaction to ensure consistency and integrity
$post=$model->findByPk(10);
$post->title='new post title';
if($post->save())
$transaction->commit();
@ursuleacv
ursuleacv / gist:9054247
Created February 17, 2014 16:45
Absolute center CSS Loading spinner
<div class="loading">Loading&#8230;</div>
/* Absolute Center CSS Spinner */
.loading {
position: fixed;
z-index: 999;
height: 2em;