Skip to content

Instantly share code, notes, and snippets.

ZMQ Notes

Basic Patterns

  • Request/Reply
  • Pub/Sub
  • Pipleline

Request Reply

@tonywok
tonywok / Hide Mobile Browser Chrome
Created April 27, 2012 17:39
Normalized hide address bar for iOS & Android on page load and orientation change
/*
* Normalized hide address bar for iOS & Android
* (c) Scott Jehl, scottjehl.com
*
* Modified by
* (c) Tony Schneider
*
* MIT License
*/
(function( win ){
@tonywok
tonywok / .bash_profile
Last active December 20, 2015 21:39
Simple little bash script for a decent bash prompt
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
GREEN="\033[0;32m"
CYAN="\033[0;36m"
BLUE="\033[0;34m"
RED="\033[0;31m"
RESET="\033[0m"
{
"app/assets/javascripts/models/*.js": {
"command": "jmodel",
"alternate": "spec/javascripts/models/%s_spec.js",
"template": "App.%S = DS.Model.extend"
},
"app/assets/javascripts/controllers/*_controller.js": {
"command": "jcontroller",
"alternate": "spec/javascripts/controllers/%s_spec.js",
@tonywok
tonywok / jsbin.osuXiBa.html
Last active December 27, 2015 13:09
Ember pattern for binding your data to other data conditionally. Useful when you have lots of properties following a naming convention that need to be copied and/or updated dependent on state. (E.g copying address to billing/shipping address)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Ember Starter Kit</title>
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/normalize/2.1.0/normalize.css">
</head>
<body>
<script type="text/x-handlebars">
@tonywok
tonywok / gist:8764367
Created February 2, 2014 07:42
Remove annoying nokogiri notice for OSX Mavericks
gem uninstall nokogiri
brew uninstall libxml2
bundle config build.nokogiri --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2
bundle install
echo "sleep at night"
@tonywok
tonywok / gist:8838149
Last active October 13, 2015 23:13
render raw json rails4/postgresql

So you need to store some JSON blobs in your database. What do you do? You have plenty of options these days. You can serialize a hash into the database. You can reach for a document store like mongodb. Or, you can lean on rails 4 postgres json data type support.

If you haven't yet upgraded to rails 4, go ahead and do that now, I'll wait...

tick, tock, looks at watch

Jokes aside, it's totally worth it.

Anywho, now that we are on rails 4, let's go ahead and stuff some JSON into the database.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Ember Starter Kit</title>
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/normalize/2.1.0/normalize.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v1.2.1.js"></script>
<script src="http://builds.emberjs.com/tags/v1.4.0/ember.js"></script>
</head>
@tonywok
tonywok / active_model_serializer.rb
Created April 2, 2014 17:37
Hacking polymorphic has_many into AMS. (e.g has_many :tasks, embed: :ids, include: true, polymorphic: true)
module ActiveModel
class Serializer
module Associations
class HasMany
def key_with_polymorphism
return @name if !option(:key) && option(:polymorphic)
key_without_polymorphism
end
alias_method_chain :key, :polymorphism
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Ember Starter Kit</title>
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/normalize/2.1.0/normalize.css">
</head>
<body>
<script type="text/x-handlebars">