A protip by tastycode about angularjs.

izzy's playlists!
Fai_Ryy
Misplaced Lens Cap

oozey mess
PUT YOUR BEARD IN MY MOUTH

bliss lane
NASA
🩵 avery cochrane 🩵
occasionally subtle
Lint Roller? I Barely Know Her

Love Begins
official daine visual archive
𓃗

PR's Tumblrdome
No title available

@theartofmadeline
No title available
sheepfilms
No title available
Claire Keane
seen from Singapore
seen from Kuwait
seen from United States
seen from United States
seen from Pakistan

seen from United States
seen from Malaysia
seen from United States
seen from Germany
seen from United Kingdom
seen from United States

seen from United States
seen from Germany

seen from France

seen from Malaysia
seen from Moldova

seen from United States

seen from United States
seen from United States
seen from Iraq
@neo-sanskrit
A protip by tastycode about angularjs.
A protip by tastycode about rspec.
inception!
TIL about embedding html directly into links.. https://gist.github.com/tastycode/5946805
Multiline regex and named capture groups in ruby 1.9
I was suprised to not be able to find an article about improving readability of regular expressions using multiline flags and named capture groups.
In ruby 1.8 you had to do something like this.
With the multiline flag "x", you could improve things somewhat.
ruby 1.9 brought named capture groups. Which allowed you to add a capture name by adding a ?<capture_name> within the capture group.
With a little magic, we can use regular expressions as the template for tiny classes that represent methods and attributes based on the capture groups within the regex.
Tiny hack, A self updating gist
This script , when executed, will update itself on github based on the GIST_ID constant in the header. Not sure what it would be useful for, but I could pull this script down then execute it from anywhere to push the changes back up to itself.
Introducing Necrohost
Announcing Necrohost.com. A tool for testing hosts under various types of network or application issues. Included are tools for testing
Redirects
Unresolvable Hosts
Unreachable Network
Please fork if you would like more features!
On Github
TIL about composing regexes
(Named capture groups are 1.9 only)
Insane Code: Holy Hash
Felt like playing with what you could do with a single function in ruby. I would like to implement some sort of powerful iterator construct that could be bound to any behavior for retrieving and iterating over a collection of any type. Mixing in enumerable to a class already gives this to us in ruby, however I wanted to take a stab at reimplementing it with an alternative dsl and delayed invocation. Here is the example
(implementation)
The result turned out quite messy, with tons of anonymous classes and nested methods. It ended up cleaner that i thought it would have been.
The resulting implementation (though completely insane). Has a couple of interesting properties.
(implementation)
The configuration and invocation of the behavior are self contained in the method, but without passing in a complex set of arguments.
The responsibility of the method, including the construction of its own configuration dsl is contained within the method's namespace. This prevents methods that are not within the area of concern of #search from being leaked to where they have no use.
Keeping in mind, that this type of insane code has plenty of shortcomings (performance especially, as Kernel#extend (for ad-hoc DCI) has been known to be non-performant, among other things). What are other ways to solve the challenge with one method?
Couldn't it be argued that Alex's method of speaking to the repository should be moved into a "domain controller" to decouple domain logic from the controller layer (similar to http://blog.firsthand.ca/2011/12/your-rails-application-is-missing.html)?
Use vim to edit any text field in MacOSX
I love vim. After working with vim for several years, i consider myself a much more formidable engineering demon when armed with my tool of choice. Unfortunately, outside of vim, my vim skills are simply not very useful. There is of course the Vimperator plugin for firefox, and the Vrome plugin for chrome. But what about every other Macosx App? I've always dreamed of being able to use vim in any text field.
Enter Vimcopy!
Vimcopy is an applescript which will
Take the current contents of the clipboard
Paste the contents into a new vim terminal
Once the file is closed, take the output of the buffer and put back on the clipboard
Paste the result into the currently active application
Unfortunately, I simply could not get applescript to perform the "cut" command for me. So essentially you must cut the current selection yourself, then run the applescript. Everything is automatic. Since it is an applescript, you would need to have a way to launch the script using a global hotkey for which I've used quicksilver and have bound vimcopy to "Ctrl+X". The process for taking the current selection and replacing it with whatever I save in vim can be reduced to simply hitting "Cmd+X", "Ctrl+X".
Proof of Concept
Check out a proof of concept here
The Applescript
This is an open cry for some macosx automation guru to make my applescript blazing fast/or reimplement using cocoa if possible
Installation
Being a vim editor yourself, I'm sure you can put together the pieces. The main thing you need to know is that you need to enable GUI scripting access for applescript through System Preferences > Universal Access > Enable access for assistive devices. Beyond that it is just a matter of copying the script to ~/Library/Scripts, and creating a trigger in quicksilver to run the script with "Ctrl+X" . Best of luck, and please keep me updated if you end up taking this to the next level!
UPDATE!: Someone has already done something like this apparently! It is a paid app (4.99) called "QuickCursor". If you are not squeemish you can install from source
Launch Shortcuts
As a user
I would like to launch common applications from the command line, even though I just remembered that i can do Command+Space, <app name>
But hey, never hurts to explore how else it could be done eh?
Fun project: Make midi keyboard act as real keyboard?
This post is essentially a response to a post on stack overflow. Essentially the OP has trouble with RSI except for when he plays a real keyboard. My theory is that proper hand position when playing a keyboard is part of learning to play the piano and may not be focused on as much where most people today are self-taught on how to type. None the less, here is a video demo:
Essentially, I learned about a program named midipipe that could intercept arbitrary midi messages and execute applescript from them. I learned how applescript sends keycodes, and found that it would be quite tedious to write a handler for every letter of the alphabet. I created an "erb" template (written in ruby) to do all the work for me as I have never encountered applescript before.
In case one does not have erb/ruby installed, the resulting script is available here. To use the script, you must create a new pipe with first element "Midi In" (you will need to choose the appropriate midi device), then create a new apple script element and paste in the code. If the midi controller messages are different, you will need to check them out with "AList" in the available elements and modify the applescript as necessary.
Exception handling via forked processes
Ruby is an amazingly versatile language, its eloquent syntax and unique community personality have created an environment where innovation and productive discourse thrive. The community has amassed a treasure trove of gems and wrappers for common C libraries. Yet, there are many cases where we must reach outside of ruby to do what needs to be done. Occasionally we must reach out to compiled binaries to get what we need and when this happens we lose a few things.
We receive exceptions from beyond the spawned process, just a return code.
Output is sent to a separate stream (STDERR)
For processes that block on IO, the originating thread from which the system call originates becomes blocked as well.
Of course these issues are addressed on a case-by-case basis depending on which binary is being executed and the importance of handling failures. Consider the case of ffmpeg, wrappers which delegate processing to the ffmpeg binary:
In this case we lose stderr to devnull and we do not catch the result of the command. As a wrapper around ffmpeg, I would hope that if ffmpeg failed that the wrapper could relay information related to the failure. Consider another example .
In this case the wrapping gem (sunspot) carefully checks the environment to minimize the possibility of issues with startup, however if we introduce an issue e.g. -Xmx256k to set the memory max to 256k for the process. The command "rake sunspot:solr:start" will silently fail.
Introducing executor
Executor aims to standardize how system calls are handled and provide:
regular means of catching exceptions by listening to process exit code
asynchronous callback suppot
regular means of redirecting stdout
Using executor
For simple usage, executor by default will redirect stderr and return the result of the command. By default, executor will raise an exception if a command reports failure:
Executor of course has some basic asynchronous support with exception handling. The callback will receive a CommandFailure exception in case of a failure (no exception is raised explicitly). I haven't had the opportunity to write tests for code that takes callbacks. Having said that, I could use some extra eyes on the async features.:
Executor was tested on 1.8.7 and 1.9.2, you can check it out on github
Rails Benchmarking Reloaded
While evaluating caching strategies in Rails 3.1, I found existing articles comparing rails cache store backends to be quite lacking and/or outdated. The last article I could find compares file_store to mem_cache_store. Given that mem_cache_store is being replaced by "Dalli", it seems that existing benchmarks comparing the available options for rails cache backends are lacking in their ability to provide value with respect to the options available today.
File Store
Memcached Store
Dalli
Mongo Store
Redis Store
Test Results
Though it looks like mongo-store demonstrates the best overall performance, it should be noted that a mongo server is unlikely to be used solely for caching (the same applies to redis), it is likely that non-caching related queries will be running concurrently on a mongo/redis server which could affect the suitability of these benchkmarks.
Another Metadata Framework
The quest for consistent metadata storage
I sought to create an web application to access my mp3's and photos remotely I wanted a new way to store information, every file should be its own record The database should be the files themselves and I should just need to maintain a directory
I needed a consistent metadata framework:
Id3 was archaic and pretty much specifically for mp3s
Exif was just for photos
Enter XMP
I found XMP which could tag mp4 files and photos both and had been in development since 2005 by adobe. It used XML and was capable of storing any type of information in any file.
Code was available in C++/Java and I immediately undertook the task of writing a native extension using Rice. I ran into environment issues and explored who I might implement the specification manually.
I checked out the specification and o_O, I could smell the stank of corporate governance IPTC schemas and namespaces everywhere, the specification had rigid expectations of using a specific schema and was full of all the nastiness of when XML came to be owned and defined by large corporate bodies.
I took the best parts of the idea
Add metadata to any file
Implement a special marker to identify an XMP segment
And added my own ideas
Use BSON (10gen's Binary JSON format)
Provide support for JSON schemas and namespaces
Of course there is no existing specification for schemas and namespaces, so the tests' namespaces refer to a google group where namespace implementation is being discussed.
Metahash
Check it out at Github