Skip to content

Instantly share code, notes, and snippets.

View ahmetabdi's full-sized avatar
:shipit:

Ahmet ahmetabdi

:shipit:
View GitHub Profile
# Shell prompt based on the Solarized Dark theme.
# Screenshot: http://i.imgur.com/EkEtphC.png
# Heavily inspired by @necolas’s prompt: https://github.com/necolas/dotfiles
# iTerm → Profiles → Text → use 13pt Monaco with 1.1 vertical spacing.
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM='gnome-256color';
elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM='xterm-256color';
fi;
You can configure git to push to the current branch using the following command
git config --global push.default current
then just do
git push
this will push the code to your current branch.
iex(1)> Tmdb.Movie.popular[:results]
[%{"adult" => false, "backdrop_path" => "/xu9zaAevzQ5nnrsXN6JcahLnG4i.jpg",
"id" => 157336, "original_title" => "Interstellar",
"popularity" => 34.1716910628099,
"poster_path" => "/nBNZadXqJSdt05SHLqgT0HuC5Gm.jpg",
"release_date" => "2014-11-05", "title" => "Interstellar", "video" => false,
"vote_average" => 8.5, "vote_count" => 2009},
%{"adult" => false, "backdrop_path" => "/c1OSRvorPXvGtFka7mgV6Jcw6jd.jpg",
"id" => 168259, "original_title" => "Furious 7",
"popularity" => 29.8393594653136,
iex(1)> Tmdb.Movie.popular
[page: 1,
results: [%{"adult" => false,
"backdrop_path" => "/xu9zaAevzQ5nnrsXN6JcahLnG4i.jpg", "id" => 157336,
"original_title" => "Interstellar", "popularity" => 34.1716910628099,
"poster_path" => "/nBNZadXqJSdt05SHLqgT0HuC5Gm.jpg",
Built-in Atom packages (84)
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
Rails.cache.fetch("cached_tweet", expires_in: 1.hour) do
Timeout::timeout(5) do
class IndexController < UITableViewController
def init
super.tap do
self.tabBarItem = UITabBarItem.alloc.initWithTitle('Index', rmq.image.resource('home'), tag: 1)
self.title = 'Index'
end
end
end
### Show stack trace for 500 errors
### (adapted from https://gist.github.com/1079020)
# Given an application, yield to a block to handle exceptions
class ExceptionRaiserApp
def initialize(app)
@app = app
end
def call(env)
@ahmetabdi
ahmetabdi / gist:9932034
Created April 2, 2014 11:05
Validating Multiple Fields in Rails
validate :unique_organisation_entry
def unique_organisation_entry
matched_entry = Organisation.where(['LOWER(name) = LOWER(?) AND LOWER(company_no) = LOWER(?) AND LOWER(postcode) = LOWER(?)', self.name, self.company_no, self.postcode]).first
errors.add(:base, 'I know you think you\'re clever, but someone already submitted that one.') if matched_entry && (matched_entry.id != self.id)
end
# =================================
# = Warped shadow for any CGLayer =
# =================================
def warpShadow(rect, offset)
size = rect.size
path = UIBezierPath.bezierPath
# Top/Right: ````|
path.moveToPoint([offset, offset])
path.addLineToPoint([size.width - offset, offset])