This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This snippet does everything I've ever wanted out of imagemagick. | |
| # Equivalent to cropping to min(width, height) by min(width, height) and resizing to N x N. | |
| # See http://www.imagemagick.org/Usage/thumbnails/#cut | |
| # If you're writing this in bash or zsh, don't forget to escape the ^ with a backslash | |
| convert -resize 256x256^ -extent 256x256 in.png out.png |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # First, download a binary distribution from | |
| # http://mina.apache.org/sshd/sshd-070.html | |
| # and copy lib/*.jar to your cwd | |
| # Load all the jar files | |
| require 'java' | |
| Dir['./*.jar'].each {|jar| require jar } | |
| # Import some Java classes | |
| java_import java.util.EnumSet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'net/ssh' | |
| class CustomPublickeyAuthenticator | |
| include PublickeyAuthenticator | |
| def authenticate(username, key, session) | |
| key = String.from_java_bytes(key.getEncoded) | |
| key = [OpenSSL::PKey::RSA.new(key).to_blob].pack('m0') | |
| # The key is now a string | |
| # Your public key authentication magic here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Sometimes you learn from Codecademy; sometimes you learn from real-life experience. Yesterday, Codecademy was offline for almost 24 hours. We want to apologize and explain what happened. | |
| What happened? | |
| At 1:09AM EST on Wednesday 2/13, we took Codecademy down to deal with a database migration issue we were facing. We tweeted about it at 1:30. Then we spent the next 24 hours behind the scenes to iron out the issue. | |
| How did it happen? | |
| Like most web applications, Codecademy stores its information — everything from your submissions in exercises to new accounts — in a database. We use a technology called MongoDB (by our friends at 10gen) to do this. Our databases have hundreds of millions of items in them and are growing larger by the second. We've been working to change the configuration of our databases so that we can migrate our data to new database structures, laying a solid foundation for future developments and features. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (status == CL_BUILD_PROGRAM_FAILURE) { | |
| // Determine the size of the log | |
| size_t log_size; | |
| clGetProgramBuildInfo(program, devices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size); | |
| // Allocate memory for the log | |
| char *log = (char *) malloc(log_size); | |
| // Get the log | |
| clGetProgramBuildInfo(program, devices[0], CL_PROGRAM_BUILD_LOG, log_size, log, NULL); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { "keys": ["super+left"], "command": "prev_view" }, | |
| { "keys": ["super+right"], "command": "next_view" } | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var teaser = _.chain(data.stories) | |
| .pluck("teaser") | |
| .filter(function(t) { return t && t.length }) | |
| .shuffle() | |
| .first() | |
| .value(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var teaser = _.chain(data.stories) | |
| .pluck("teaser") | |
| .filter(function(t) { return !!t.length; }) | |
| .shuffle() | |
| .first() | |
| .value(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| khan | |
| khanacaste | |
| khanacre | |
| khanal | |
| khanalbumin | |
| khanamed | |
| khanarial | |
| khanarium | |
| khanation | |
| khanational |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // promises is an array of jqXHRs or what have you | |
| var deferreds = _.map(promises, function(promise) { | |
| var deferred = $.Deferred(); | |
| promise.then( | |
| function() { | |
| deferred.resolve(true); | |
| }, | |
| function() { | |
| deferred.resolve(false); | |
| } |