Rails flash messages with AJAX requests
This file contains 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 'active_record' | |
require 'arel' | |
# Ruby-like syntax in AR conditions using the underlying Arel layer (Rails >= 3.0). | |
# | |
# What you would usually write like this: | |
# | |
# User.where(["users.created_at > ? AND users.name LIKE ?", Date.yesterday, "Mary"]) | |
# | |
# can now be written like this (note those parentheses required by the operators precedences): |
This file contains 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
@Grapes([ | |
@Grab('redis.clients:jedis:1.5.1'), | |
@GrabConfig(systemClassLoader=true) | |
]) | |
import redis.clients.jedis.* | |
performTest("unencoded", null) {n, e-> | |
n.toString() | |
} |
This file contains 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
#!/bin/bash | |
# from | |
# http://bergamini.org/computers/creating-favicon.ico-icon-files-with-imagemagick-convert.html | |
convert source-WxW.png -resize 256x256 -transparent white favicon-256.png | |
convert favicon-256.png -resize 16x16 favicon-16.png | |
convert favicon-256.png -resize 32x32 favicon-32.png | |
convert favicon-256.png -resize 64x64 favicon-64.png | |
convert favicon-256.png -resize 128x128 favicon-128.png |
This file contains 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
class Object | |
def try_all(*methods) | |
values = [self] | |
methods.each do |method| | |
value = values.last.try(method) | |
return nil if value.nil? | |
values << value | |
end | |
values.last |
This file contains 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
/* | |
* bcd2number -> takes a nodejs buffer with a BCD and returns the corresponding number. | |
* input: nodejs buffer | |
* output: number | |
*/ | |
var bcd2number = function(bcd) | |
{ | |
var n = 0; | |
var m = 1; | |
for(var i = 0; i<bcd.length; i+=1) { |
This file contains 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
/****** Current Format ******/ | |
// Basic Message | |
metadata = { | |
id: 1234234234, // Randomly generated by the client. Used for receiving success/fail callbacks | |
client_id: 123456 // Sent from the server with the `websocket_rails.client_connected` event which is sent after the connection is opened. Store this and send it with each message. | |
data: {name: 'shoes'} // Arbitrary data. Can be Object or String. This is available through #message or #data in the controller. | |
} | |
event = ["products.new", metadata] |
This file contains 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 is a skeleton for testing models including examples of validations, callbacks, | |
# scopes, instance & class methods, associations, and more. | |
# Pick and choose what you want, as all models don't NEED to be tested at this depth. | |
# | |
# I'm always eager to hear new tips & suggestions as I'm still new to testing, | |
# so if you have any, please share! | |
# | |
# @kyletcarlson | |
# | |
# This skeleton also assumes you're using the following gems: |
This file contains 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
The code in this gist is | |
copyright (C) 2013 Susanne Oberhauser-Hirschoff | |
All rights reserved. | |
Redistribution and use in source and binary forms, with or without | |
modification, are permitted provided that the following conditions are met: | |
* Redistributions of source code must retain the above copyright | |
notice, this list of conditions and the following disclaimer. | |
* Redistributions in binary form must reproduce the above copyright |
This file contains 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
# Syntax sugar | |
class ArrayValidator < EnumValidator | |
end |
OlderNewer