Orchestrated Objective Reduction

This is old news, actually. I came across an article posted on January 2014, that talks about a theory… i had just no idea existed, and it blew my mind.

It’s called Orch-OR: the idea? you cannot model consciousness with just a huge neural network. There’s an orchestrated quantum effect that affects synapse.

This theory was proposed by Roger Penrose in the early 90’s, and… cool thing is that, precisely, quantum vibrations inside brain neurons have been proved to exist.

(I know, 2014, i came late to the party!).

Reference here!

Fish Shell

Installing Fish:

[cc lang=”bash”]
brew install fish
[/cc]

Displaying the branch name in the prompt:

Place the following script here: ~/.config/fish/config.fish

[cc lang=”bash”]
set fish_git_dirty_color red
set fish_git_not_dirty_color green

function parse_git_branch
set -l branch (git branch 2> /dev/null | grep -e ‘\* ‘ | sed ‘s/^..\(.*\)/\1/’)
set -l git_diff (git diff)

if test -n “$git_diff”
echo (set_color $fish_git_dirty_color)$branch(set_color normal)
else
echo (set_color $fish_git_not_dirty_color)$branch(set_color normal)
end
end

function fish_prompt
if test -d .git
printf ‘%s@%s %s%s%s:%s> ‘ (whoami) (hostname|cut -d . -f 1) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal) (parse_git_branch)
else
printf ‘%s@%s %s%s%s> ‘ (whoami) (hostname|cut -d . -f 1) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
end
end
[/cc]

Reference here (Thanks for sharing the snippet!)

Debugging Autolayout

If you need to debug the constraints that produced any view layout, just hit LLVM, and type:

[cc lang=”objc”]
po [[UIWindow keyWindow] _autolayoutTrace]
[/cc]

This will help you get the Autolayout Trace. Pick up the troublesome view, find its memory address, and then try:

[cc lang=”objc”]
po [0x12341234 constraintsAffectingLayoutForAxis:1]
[/cc]

Note that you should replace 0x12341234 with the memory address of the view you’d like to debug. AxisX = 0, while AxisY = 1.

Props to this extremely useful post.

iOS 8 Autosizing Cells

The latest iOS release (8.0 at the time this was written!) added a new cool feature: autosizing cells. Meaning that we don’t really need to implement tableView:heightForRowAtIndexPath: anymore.

How can we enable this?. Super simple, just add the following snippet:

[cc lang=”objc”]
self.tableView.estimatedRowHeight = SomeConstant;
self.tableView.rowHeight = UITableViewAutomaticDimension;
[/cc]

Now, here’s the deal. iOS 7 still requires tableView:heightForRowAtIndexPath: to be implemented. And if you do implement it, iOS 8 will disregard the Automatic Dimension settings.

Solution?.. import objc/runtime.h, and place this hack in your UITableView’s delegate:

[cc lang=”objc”]
– (BOOL)respondsToSelector:(SEL)aSelector {
if (sel_isEqual(aSelector, @selector(tableView:estimatedHeightForRowAtIndexPath:)) ||
sel_isEqual(aSelector, @selector(tableView:heightForRowAtIndexPath:))) {
return false;
}
return [super respondsToSelector:aSelector];
}
[/cc]

YES. It’s a hack =)