Skip to content

Instantly share code, notes, and snippets.

View BartlomiejSkwira's full-sized avatar

Bartek Skwira BartlomiejSkwira

View GitHub Profile
@BartlomiejSkwira
BartlomiejSkwira / include_helpers.rb
Created August 26, 2013 11:12
RailsApi - include helpers
#include ActionController::Helpers and
#provide your own Helper modules to the view using the 'helper' method
#In my API application I created a RenderingController which acts as a superclass for all controllers that do render:
class RenderingController < ApplicationController
include AbstractController::Layouts
include AbstractController::Translation
include ActionController::ImplicitRender
include ActionController::Helpers
<div ng-class="{ active: user.id == activeId }">
Dynamic
</div>
<!-- In this case active class will be added to the element as long as user.id matches activeId from the $scope object! -->
@BartlomiejSkwira
BartlomiejSkwira / install_postgres.sh
Created August 21, 2013 13:16
install postgres and configure
sudo apt-get install postgres
sudo apt-get install postgres-contrib
#/etc/postgresql/9.1/main/pg_hba.conf
# "local" is for Unix domain socket connections only
local all all trust
sudo su
passwd postgres #set password
@BartlomiejSkwira
BartlomiejSkwira / non greedy regex
Created August 21, 2013 10:24
get all occurences of regex without selecting all text
"file path/level1/level2" xxx some="xxx"
/location="(.*?)"/
#faster bundle install
https://github.com/rubygems/rubygems/issues/513#issuecomment-14964071
tar xvzf file-1.0.tar.gz - to uncompress a gzip tar file (.tgz or .tar.gz)
tar xvjf file-1.0.tar.bz2 - to uncompress a bzip2 tar file (.tbz or .tar.bz2)
tar xvf file-1.0.tar - to uncompressed tar file (.tar)
#x = eXtract, this indicated an extraction c = create to create )
#v = verbose (optional) the files with relative locations will be displayed.
#z = gzip-ped; j = bzip2-zipped
#f = from/to file ... (what is next after the f is the archive file)
@BartlomiejSkwira
BartlomiejSkwira / sleep.js
Created August 13, 2013 12:56
wait/sleep for a period
setTimeout(function() {
// rest of code here
}, 2000);
@BartlomiejSkwira
BartlomiejSkwira / heroku_config.sh
Created August 9, 2013 08:54
heroku correct app config
git remote add heroku [email protected]:your-app.git
@BartlomiejSkwira
BartlomiejSkwira / center_viewport.css
Created August 6, 2013 09:54
center absolutely in viewport
#centerme
{
position: absolute;
left: 50%;
top: 50%;
/* You must set a size manually */
width: 100px;
height: 50px;
@BartlomiejSkwira
BartlomiejSkwira / route_change.js
Created August 5, 2013 12:28
Watch route change
$scope.$on('$routeChangeStart', function(next, current) {
... you could trigger something here ...
});