Category Archives: Auto

Setting up Sublime Text 2 (alexmaccaw.com)

This post has been automatically generated. I use this blog to collect links that I have bookmarked. All activity is automated.

maccman

JavaScript programmer, O’Reilly author, working at Stripe

  Svbtle April 9, 2013

I recently decided it was finally time to part ways with TextMate, my trusty companion for these last few years, and start the hunt for a new editor. After a quick Twitter poll the unanimous advice was that I should try Sublime Text 2.

After a few weeks of using Sublime Text I can safely say that it’s the best editor I’ve used. It’s fast, extendable and hasn’t ever crashed on me. That said, that no editor is perfect and Sublime Text does require a fair bit of initial configuration.


After you’ve downloaded & installed the editor, the first step to configuring Sublime Text 2 is to install the package manager. I’m hoping in future versions of the editor this package manager will come bundled, but for now it requires a separate installation. Run Sublime Text, Press ctrl ` (control backtick) to open the editor’s console, and paste in the code listed here.

Once the manager is set up, you can install packages with ⌘⇧p (command shift p) and typing Install Package.

Theme – Soda

Sublime’s initial look leaves a lot to be desired. However, luckily there’s a beautiful theme called Soda. To install Soda, open the package manager (⌘⇧p), type ‘Install Package ↵’, and then ‘Theme – Soda ↵’.

Screen Shot 2013-04-08 at 12.07.47 PM.png

To activate the theme, open Sublime’s preferences ⌘, (command comma), which is a JSON file, and set the "theme" key to "Soda Light.sublime-theme" (Remember to check commas).

{
  "theme": "Soda Light.sublime-theme"
}

You may have to restart the editor, or at least open a new window, for the theme to activate.

Extending the editor

There are a few other packages to install:

Follow the same steps as before to install the packages, ⌘⇧p and "Install package".

Tabs & Spaces

The default indentation style uses tabs instead of spaces, and it’s likely that you’ll want to switch this (unless you solely program in a language where that’s the convention, such as Go). Open Sublime’s preferences (Settings – User or ⌘,) and add:

{
  "tab_size": 2,
  "translate_tabs_to_spaces": true
}

If you’re anything like me, and dread trailing white space, then you should install the TrailingSpaces package. You’ll need to change the default preferences for the plugin too. Open TrailingSpace’s preferences (Preferences -> Package Settings -> TrailingSpaces -> Settings – User), and add:

{
  "trailing_spaces_include_current_line": false
}

Also add this to your global user preferences (⌘,):

 "trim_trailing_white_space_on_save": true

Key bindings

There’s a key binding I used the whole time in TextMate: ⌘ ctrl r to reveal the currently opened file in the sidebar. You can add this to Sublime by opening the key bindings preferences (Preferences -> Key Bindings – User) and adding:

[
  {"keys": ["ctrl+super+r"], "command": "reveal_in_side_bar"}
]

Sublime’s fuzzy search (⌘ t) is incredibly fast and convenient, and it’s my primary way of navigating around my projects. As well as navigating by file name, you can go to a particular line in a file by typing :123 (colon line number) or to a particular method by typing #name (hash method name).

Command line

Surprisingly Sublime Text doesn’t come with a easily accessible binary, since this is probably the primary way developers will open the editor. That said, you can easily add support by creating a symlink:

ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/bin/subl

I also use an alias in my ~/.bash_profile file, allowing me to easily open a directory from the terminal:

alias e='subl . &'

Icon

Sublime’s default icon is fairly ugly, but there are a few replacements on Dribbble. One of my favorites is by Elliot Jackson. To install it, download the icns file and replace the application’s icon:

$ mv ~/Downloads/st2.icns /Applications/Sublime\ Text\ 2.app/Contents/Resources/Sublime\ Text\ 2.icns 

sublime-text-2.png

Pasting

One suggestion from Jason Barry is to use ‘Paste and Indent’ for ⌘V instead of the standard ‘Paste’. This adjusts your indentation to automatically match the context it’s pasted in. To do this, put the following in your Key Bindings – User file:

[
  { "keys": ["super+v"], "command": "paste_and_indent" }, 
  { "keys": ["super+shift+v"], "command": "paste" } 
]

More packages

A few more packages you may find useful:

  • Git – Git blame/branch support
  • CoffeeScript – .coffee syntax highlighting
  • Eco – .eco syntax highlighting
  • Stylus – .styl syntax highlighting
  • Sass – .sass syntax highlighting
  • SublimeLinter – lint code as you type
  • GitGutter – show Git diffs in the gutter

Conclusion

So that’s a fair bit of setting up required for an editor, most of which you’d think would be the default configuration. Sublime Text 2 definitely needs a bit of polishing from a product perspective. The default website, icon, and theme are ugly to say the least, and it would be convenient to be able to install the editor through the App Store. A GUI for configuration would be a good idea as storing preferences in JSON files may appeal to programmers, but it definitely alienates designers.

That said it’s early days for the editor, and the core framework has clearly been built extremely well. It’s ridiculously fast, stable and very extendable. I love it and absolutely recommend you try it.

1,474

Kudos

Read this next

Abba – JavaScript a/b testing

←   Full blog

© 2013 SVBTLE

maccman

JavaScript programmer, O’Reilly author, working at Stripe

  Svbtle April 9, 2013

I recently decided it was finally time to part ways with TextMate, my trusty companion for these last few years, and start the hunt for a new editor. After a quick Twitter poll the unanimous advice was that I should try Sublime Text 2.

After a few weeks of using Sublime Text I can safely say that it’s the best editor I’ve used. It’s fast, extendable and hasn’t ever crashed on me. That said, that no editor is perfect and Sublime Text does require a fair bit of initial configuration.


After you’ve downloaded & installed the editor, the first step to configuring Sublime Text 2 is to install the package manager. I’m hoping in future versions of the editor this package manager will come bundled, but for now it requires a separate installation. Run Sublime Text, Press ctrl ` (control backtick) to open the editor’s console, and paste in the code listed here.

Once the manager is set up, you can install packages with ⌘⇧p (command shift p) and typing Install Package.

Theme – Soda

Sublime’s initial look leaves a lot to be desired. However, luckily there’s a beautiful theme called Soda. To install Soda, open the package manager (⌘⇧p), type ‘Install Package ↵’, and then ‘Theme – Soda ↵’.

Screen Shot 2013-04-08 at 12.07.47 PM.png

To activate the theme, open Sublime’s preferences ⌘, (command comma), which is a JSON file, and set the "theme" key to "Soda Light.sublime-theme" (Remember to check commas).

{
  "theme": "Soda Light.sublime-theme"
}

You may have to restart the editor, or at least open a new window, for the theme to activate.

Extending the editor

There are a few other packages to install:

Follow the same steps as before to install the packages, ⌘⇧p and "Install package".

Tabs & Spaces

The default indentation style uses tabs instead of spaces, and it’s likely that you’ll want to switch this (unless you solely program in a language where that’s the convention, such as Go). Open Sublime’s preferences (Settings – User or ⌘,) and add:

{
  "tab_size": 2,
  "translate_tabs_to_spaces": true
}

If you’re anything like me, and dread trailing white space, then you should install the TrailingSpaces package. You’ll need to change the default preferences for the plugin too. Open TrailingSpace’s preferences (Preferences -> Package Settings -> TrailingSpaces -> Settings – User), and add:

{
  "trailing_spaces_include_current_line": false
}

Also add this to your global user preferences (⌘,):

 "trim_trailing_white_space_on_save": true

Key bindings

There’s a key binding I used the whole time in TextMate: ⌘ ctrl r to reveal the currently opened file in the sidebar. You can add this to Sublime by opening the key bindings preferences (Preferences -> Key Bindings – User) and adding:

[
  {"keys": ["ctrl+super+r"], "command": "reveal_in_side_bar"}
]

Sublime’s fuzzy search (⌘ t) is incredibly fast and convenient, and it’s my primary way of navigating around my projects. As well as navigating by file name, you can go to a particular line in a file by typing :123 (colon line number) or to a particular method by typing #name (hash method name).

Command line

Surprisingly Sublime Text doesn’t come with a easily accessible binary, since this is probably the primary way developers will open the editor. That said, you can easily add support by creating a symlink:

ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/bin/subl

I also use an alias in my ~/.bash_profile file, allowing me to easily open a directory from the terminal:

alias e='subl . &'

Icon

Sublime’s default icon is fairly ugly, but there are a few replacements on Dribbble. One of my favorites is by Elliot Jackson. To install it, download the icns file and replace the application’s icon:

$ mv ~/Downloads/st2.icns /Applications/Sublime\ Text\ 2.app/Contents/Resources/Sublime\ Text\ 2.icns 

sublime-text-2.png

Pasting

One suggestion from Jason Barry is to use ‘Paste and Indent’ for ⌘V instead of the standard ‘Paste’. This adjusts your indentation to automatically match the context it’s pasted in. To do this, put the following in your Key Bindings – User file:

[
  { "keys": ["super+v"], "command": "paste_and_indent" }, 
  { "keys": ["super+shift+v"], "command": "paste" } 
]

More packages

A few more packages you may find useful:

  • Git – Git blame/branch support
  • CoffeeScript – .coffee syntax highlighting
  • Eco – .eco syntax highlighting
  • Stylus – .styl syntax highlighting
  • Sass – .sass syntax highlighting
  • SublimeLinter – lint code as you type
  • GitGutter – show Git diffs in the gutter

Conclusion

So that’s a fair bit of setting up required for an editor, most of which you’d think would be the default configuration. Sublime Text 2 definitely needs a bit of polishing from a product perspective. The default website, icon, and theme are ugly to say the least, and it would be convenient to be able to install the editor through the App Store. A GUI for configuration would be a good idea as storing preferences in JSON files may appeal to programmers, but it definitely alienates designers.

That said it’s early days for the editor, and the core framework has clearly been built extremely well. It’s ridiculously fast, stable and very extendable. I love it and absolutely recommend you try it.

1,474

Kudos

Read this next

Abba – JavaScript a/b testing

←   Full blog

© 2013 SVBTLE

via Hacker News 20 http://blog.alexmaccaw.com/sublime-text

Advertisements

Leave a comment

Filed under Auto

Breaking down Amazon’s mega dropdown

This post has been automatically generated. I use this blog to collect links that I have bookmarked. All activity is automated.

The hover effects on Amazon’s big ‘ole “Shop by Department” mega dropdown are super fast. Look’it how quick each submenu fills in as your mouse moves down the list:

image

It’s instant. I got nerd sniped by this. Most dropdown menus have to include a bit of a delay when activating submenus. Here’s an old Khan Academy dropdown as an example:

image

See the delay? You need that, because otherwise when you try to move your mouse from the main menu to the submenu, the submenu will disappear out from under you like some sort of sick, unwinnable game of whack-a-mole. Enjoy this example from bootstrap’s dropdown menus:

image
I love bootstrap, don’t get it twisted. Just a good example of submenu frustration.

It’s easy to move the cursor from Amazon’s main dropdown to its submenus. You won’t run into the bootstrap bug. They get away with this by detecting the direction of the cursor’s path.

image
If the cursor moves into the blue triangle the currently displayed submenu will stay open for just a bit longer.

At every position of the cursor you can picture a triangle between the current mouse position and the upper and lower right corners of the dropdown menu. If the next mouse position is within that triangle, the user is probably moving their cursor into the currently displayed submenu. Amazon uses this for a nice effect. As long as the cursor stays within that blue triangle the current submenu will stay open. It doesn’t matter if the cursor hovers over “Appstore for Android” momentarily — the user is probably heading toward “Learn more about Cloud Drive.”

And if the cursor goes outside of the blue triangle, they instantly switch the submenu, giving it a really responsive feel.

So if you’re as geeky as me and think something this trivial is cool, I made a jQuery plugin that fires events when detecting this sort of directional menu aiming: jQuery-menu-aim. We’re using it in the new Khan Academy “Learn” menu:

image

I think it feels snappy. I’m not ashamed to copy Amazon. I’m sure this problem was solved years and years ago, forgotten, rediscovered, solved again, forgotten, rediscovered, solved again.

If anyone else on the planet ends up finding a use for jQuery-menu-aim, I’d be grateful to know what you think.


Thanks go to Ben Alpert for helping me understand the linear algebra / cross-product magic Amazon uses to detect movement inside the “blue triangle.” I ended up going w/ a cruder slope-based approach, mostly b/c I’ve lost all intuitive understanding of linear algebra. Sad. Need to watch more KA videos.

via Hacker News http://bjk5.com/post/44698559168/breaking-down-amazons-mega-dropdown

Leave a comment

Filed under Auto

“I Want Hue” – Colors for Data Scientists

This post has been automatically generated. I use this blog to collect links that I have bookmarked. All activity is automated.

See also our other tools at Médialab Tools!

And a huge thanks to these inspiring works:

Chroma.js

I massively use this excellent js library to convert colors. If you have not done it yet, look at this post. You’ll understand much useful things about color in dataviz.

ColorBrewer

Very famous tool, that showed the way few years ago. If you do not know it, you must take a look.

via Hacker News http://tools.medialab.sciences-po.fr/iwanthue/

Leave a comment

Filed under Auto

Turn your browser into a notepad with one line

This post has been automatically generated. I use this blog to collect links that I have bookmarked. All activity is automated.

Sometimes I just need to type garbage. Just to clear out my mind. Using editors to type such gibberish annoys me because it clutters my project workspace (I’m picky, I know).

So I do this. Since I live in the browser, I just open a new tab and type in the url tab.

data:text/html, <html contenteditable>

Voila, browser notepad.

You don’t need to remember it. It’s not rocket science. We are using the Data URI’s format and telling the browser to render an html (try “javascript:alert(‘Bazinga’);”). The content of said html is a simple html line with the html5 attribute contenteditable. This works only on modern browsers that understand this attribute. Click and type!

via Hacker News https://coderwall.com/p/lhsrcq

Leave a comment

Filed under Auto

Machine Learning Cheat Sheet (for scikit-learn)

This post has been automatically generated. I use this blog to collect links that I have bookmarked. All activity is automated.

As you hopefully have heard, we at scikit-learn are doing a user survey (which is still open by the way).
One of the requests there was to provide some sort of flow chart on how to do machine learning.

As this is clearly impossible, I went to work straight away.

This is the result:

Needless to say, this sheet is completely authoritative.

Thanks to Rob Zinkov for pointing out an error in one yes/no decision.

More seriously: this is actually my work flow / train of thoughts whenever I try to solve a new problem. Basically, start simple first. If this doesn’t work out, try something more complicated.
The chart above includes the intersection of all algorithms that are in scikit-learn and the ones that I find most useful in practice.

Only that I always start out with “just looking”. To make any of the algorithms actually work, you need to do the right preprocessing of your data – which is much more of an art than picking the right algorithm imho.

Anyhow, enjoy 😉

via Hacker News http://peekaboo-vision.blogspot.de/2013/01/machine-learning-cheat-sheet-for-scikit.html

Leave a comment

Filed under Auto

Worst. Bug. Ever.

This post has been automatically generated. I use this blog to collect links that I have bookmarked. All activity is automated.

Some bugs are the worst because they cost money. Some because they cost lives.

Others would cite bugs buried deep in a framework or hardware as “the worst”.

For me, the worst kind of bugs are those were the solution, in hindsight, seemed so obvious. You end up more frustrated with the bug after knowing the fix.


I encountered my worst bug during a summer internship after my sophomore year of school. I was helping a research team at Purdue write simulation tools for nanophotonics — I say this not to sound like I was some kind of genius, but to highlight that I was in over my head in a very unfamiliar domain.

A group of research scientists and grad students would work out the math needed to simulate the performance of different nano-scale lenses and I was responsible for wrapping the computations in a web interface and plotting the results.

The team had an existing set of MATLAB scripts that they used internally, but these scripts were hard to modify and distribute. But, on the bright side, I could hook into the MATLAB scripts and leverage their existing work.

When I finally got everything wired up and started comparing the results of a few test cases, they didn’t match. I did my best to debug the MATLAB script, but the math was outside of my comprehension (optics theorems, higher order integrals, and complex numbers). And when I ran the simulation with the same inputs in the stand-alone script, I would get the correct results. Hmm.

The web interface was built on a proprietary framework — it could leverage an entire grid computing cluster as the backend, but wasn’t exactly something that StackOverflow could help with.

After about of week of stepping through the code line by line (even verifying some of the calculations by hand), I finally isolated the section of code where the results diverged.

for i=1:length(LensLayers)
  d[i] = compute_diffraction_at_wavelength(LensLayers[i], WAVELENGTH)
end

It seemed pretty innocuous; loop over an array, perform a calculation on each element, store the result in another array.

Do you see the bug?

Remember when I said there were some PhD-level computations being done? Most of them dealt with complex numbers, which are natively support in MATLAB like so:

x = 2 + 3*i

Figure it out yet?

I was using i as my loop index, but as a side-effect the imaginary constant i in MATLAB was getting overwritten! So 2 + 3*i was evaluating to 5 for the first iteration, 8 for the second, etc. Sigh.

Changing the loop variable name immediately fixed the problem and the results became correct (an alternate solution is to use 3i instead of 3*i).


To this day, I’ve never run across another bug with such a frustratingly obvious solution.

It may have taken three weeks to solve, but at least I got a good “Worst. Bug. Ever.” story out of it.

via Hacker News http://swanson.github.com/blog/2013/01/20/worst-bug-ever.html

Leave a comment

Filed under Auto

HackerRank Will Host Back To School Hackathon, Bringing College Students To Hot Startups

This post has been automatically generated. I use this blog to collect links that I have bookmarked. All activity is automated. hackerrank logo

HackerRank has hosted college-focused hackathons before, but on February 2, it plans to connect some of the top coding talent in universities with some of the best-known companies in Silicon Valley.

Developed by the same company behind InterviewStreet, a site where companies find programmers by hosting “CodeSprints,” the HackerRank service launched last fall at the TechCrunch Disrupt conference. Co-founder Vivek Ravisankar said the goal is to create a community where hackers can complete programming challenges and see how they stack up against others. Unlike Coursera and Udacity, HackerRank is less focused on teaching you the basics of programming and more on letting coders practice their skills, he said.

For now, Ravisankar said that InterviewStreet is the company’s moneymaker, while at HackerRank he’s just trying to “build the user base and a very sticky platform.” Ultimately, he plans to make money by connecting programmers with companies they want to work for, but he said that will be a purely opt-in system.

As for the upcoming Back to School Challenge, Ravisankar said he has realized that college students, especially those who don’t go to a school in the San Francisco Bay Area, don’t really know much about Silicon Valley. The contest’s main prize is supposed to address that. The top 10 competitors will receive an all-expenses-paid trip to Silicon Valley, where HackerRank has organized tours at a number of companies, including Quora, Counsyl, PocketGems, OpenTable, RocketFuel, Weebly, Scribd, Pinterest, and Twitter. There are other prizes — the top prize includes $2,000, a meeting with a partner at Y Combinator, and office hours with the HackerRank founders.

The contest will take place over 24 hours and consist of five challenges, with the first one focused on artificial intelligence. Ravisankar said he’ll be doing outreach at more than 30 schools, including Stanford, Berkeley, and Purdue, but any college student can participate — you just need to have a .edu email address.

Ravisankar said he’s hoping to host these types of Back to School challenges three or four times every year. You can read more and sign up here.

via TechCrunch http://techcrunch.com/2013/01/07/hackerrank-back-to-school/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+Techcrunch+%28TechCrunch%29

Leave a comment

Filed under Auto