Skip to content

Instantly share code, notes, and snippets.

View lbadura's full-sized avatar

Lukasz Badura lbadura

View GitHub Profile
@lbadura
lbadura / gist:1185780
Created September 1, 2011 09:19
Current git branch in shell prompt
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "("${ref#refs/heads/}")"
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
PS1="\H$GREEN{$RED\W$GREEN}-$GREEN{$RED\$(parse_git_branch)$GREEN}-$YELLOW{$GREEN\$(date +%H:%M)$YELLOW}\n$GREEN$ "
@lbadura
lbadura / nginx
Created September 1, 2011 20:34 — forked from nofxx/nginx
nginx rc.d script archlinux
#!/bin/bash
# NGINX RC.D SCRIPT
# Archlinux
NGINX_CONFIG="/opt/nginx/conf/nginx.conf"
NGINX_BIN="/opt/nginx/sbin/"
#. /etc/conf.d/nginx
. /etc/rc.conf
. /etc/rc.d/functions
@lbadura
lbadura / installation.sh
Created September 19, 2011 12:24 — forked from mikhailov/installation.sh
Nginx+passenger application config: ssl redirection, http headers, passenger optimal settings. see details: http://mikhailov.posterous.com/nginx
$ cd /usr/src
$ wget http://nginx.org/download/nginx-0.8.52.tar.gz
$ tar xzvf ./nginx-0.8.52.tar.gz
$ rm ./nginx-0.8.52.tar.gz
$ gem install s3sync capistrano capistrano-ext passenger --no-ri --no-rdoc
$ passenger-install-nginx-module
# Automatically download and install Nginx? 2. No: I want to customize my Nginx installation
# Where is your Nginx source code located?: /usr/src/nginx-0.8.52
# Where do you want to install Nginx to?: /opt/nginx
Started GET "/en/advisor/offers/10,associate-accountant-krakow-hitachi" for 77.252.243.105 at 2011-11-16 14:39:38 +0100
Processing by Advisor::OffersController#show as HTML
Parameters: {"id"=>"10,associate-accountant-krakow-hitachi", "locale"=>"en"}
User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 2 LIMIT 1
Role Load (0.3ms) SELECT `roles`.* FROM `roles` INNER JOIN `roles_users` ON `roles`.id = `roles_users`.role_id WHERE ((`roles_users`.user_id = 2))
Offer Load (0.3ms) SELECT `offers`.* FROM `offers` WHERE `offers`.`id` = 10 LIMIT 1
Company Load (0.2ms) SELECT `companies`.* FROM `companies` WHERE `companies`.`id` = 175 LIMIT 1
FacebookUser Load (0.2ms) SELECT `facebook_users`.* FROM `facebook_users` WHERE (`facebook_users`.user_id = 2) LIMIT 1
SQL (0.2ms) SELECT COUNT(*) FROM `offers` WHERE (`offers`.company_id = 175)
SQL (0.1ms) BEGIN
class AttachedFile < ActiveRecord::Base
belongs_to :attachable, :polymorphic => true
attr_accessible :file, :plan_id
validates :file, :presence => true
mount_uploader :file do
def store_dir
"uploads/#{model.attachable_type.downcase.pluralize}"
end
end
# on loading the page
:3000/:19GET http://localhost:3000/assets/ads/ad.js?body=1
:3000/:19GET http://localhost:3000/assets/ads/index.js?body=1
:3000/:19GET http://localhost:3000/assets/views/ads/ads_index.js?body=1
# after clicking find it
jquery.js:8241XHR finished loading: "http://localhost:3000/api/listings?what=&where=Seattle%2C+WA&limit=10".
search_index.js:157Uncaught TypeError: undefined is not a function
jquery.js:8241XHR finished loading: "http://localhost:3000/api/ads?what=&where=Seattle%2C+WA&limit=6".
search_index.js:157Uncaught TypeError: undefined is not a function
@lbadura
lbadura / rbenv-install-system-wide.sh
Created May 21, 2012 11:13 — forked from devsigner/rbenv-install-system-wide.sh
rbenv install ruby 1.9.3-p125 on Debian 6 Squeeze
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential git-core curl libssl-dev \
libreadline5 libreadline5-dev \
zlib1g zlib1g-dev \
libmysqlclient-dev \
libcurl4-openssl-dev \
libxslt-dev libxml2-dev
woland(master)-{17:06}
$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [i686-linux]
woland(master)-{17:08}
$ script/server
/home/lukasz/.rvm/gems/ruby-1.8.7-p358@aaero/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:55: uninitialized constant ActiveSupport::Dependencies::Mutex (NameError)
from /home/lukasz/.rvm/gems/ruby-1.8.7-p358@aaero/gems/activesupport-2.3.8/lib/active_support.rb:57:in `require'
from /home/lukasz/.rvm/gems/ruby-1.8.7-p358@aaero/gems/activesupport-2.3.8/lib/active_support.rb:57
from /home/lukasz/.rvm/gems/ruby-1.8.7-p358@aaero/gems/rails-2.3.8/lib/commands/server.rb:1:in `require'
from /home/lukasz/.rvm/gems/ruby-1.8.7-p358@aaero/gems/rails-2.3.8/lib/commands/server.rb:1
@lbadura
lbadura / gist:8556338
Created January 22, 2014 10:12
Render an authorization error if any of Backbone's syncs result with 401 response
originalSync = Backbone.sync
app = this
Backbone.sync = (method, model, opts) ->
dfd = $.Deferred()
if opts
dfd.then(opts.success, opts.error)
xhr = originalSync(method, model, _.omit(opts, 'success', 'error'))
xhr.done(dfd.resolve)
xhr.fail ->
@lbadura
lbadura / keybase.md
Created February 26, 2015 09:34
keybase.md

Keybase proof

I hereby claim:

  • I am lbadura on github.
  • I am lbadura (https://keybase.io/lbadura) on keybase.
  • I have a public key whose fingerprint is 38F6 A438 98CD 83F3 0FB8 9428 3B0E 2C44 3CE4 04F9

To claim this, I am signing this object: