Skip to content

Instantly share code, notes, and snippets.

@adorr
adorr / gist:6926662
Last active December 25, 2015 05:48
require 'rubygems'
require 'oauth'
# KEY and SECRET are available in Desk.com Admin -> Settings -> API ->
# My Applications -> Key and Secret fields
KEY = "YOUR_OAUTH_KEY"
SECRET = "YOUR_OAUTH_SECRET"
SITE = "https://yoursite.desk.com"
# start the process by requesting a token
<?php
$fields = array(
'file_name' => "wallpaper.jpg",
'content-type' => "image/jpg",
'content' => '"'.base64_encode(file_get_contents("./wallpaper.jpg")).'"'
);
$fields_string = json_encode($fields);
regex = /foo/;
//regex = /foo/g;
"foobarfoobar".replace(regex, function(str) {
if (RegExp.rightContext == "") {
return "ninja";
} else {
return "pirate";
}
});
var target = target || "_blank";
var re = new RegExp("\\b((?:[a-z][\\w-]+:(?:\/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\\s()<>]+|\(([^\\s()<>]+|(\([^\\s()<>]+\)))*\))+(?:\(([^\\s()<>]+|(\([^\\s()<>]+\)))*\)|[^\\s`!()\[\]{};:\'\".,<>?]))","g");
text = "<a target=\"_blank\" href=\"http://www.google.com/\">http://www.google.com/</a>" +
" <a target=\"_blank\" href=\"http://www.desk.com/\">http://www.desk.com/</a>"
text = text.replace(re, function(str) {
var left = RegExp.leftContext;
// Chrome sometimes throws an exception when calling rightContext
// var right; try { right = RegExp.rightContext; } catch(e) { right = ""; };
{% raw %}
<notextile>
{% if ‘something’ %}
Go to {{ help.where }}
{% endif %}
</notextile>
{% endraw %}
#submission_view_modal {
background-image: url("../images/submission-view-modal.png");
background-repeat: no-repeat;
position: absolute;
top: 74px;
left:11px;
z-index: 1001;
padding: 12px;
width: 475px;
height: 465px;
~> Starting full deploy
~> Copying to /data/tabs_r192/releases/20110829191948
~> Ensuring proper ownership
~> Gemfile detected, bundling gems
/usr/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:368:in `ensure_required_rubygems_version_met': ZenTest requires RubyGems version ~> 1.8. Try 'gem update --system' to update RubyGems itself. (Gem::InstallError)
from /usr/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:136:in `install'
from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/source.rb:96:in `install'
from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/installer.rb:55:in `block in run'
from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `block in each'
from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `each'
@adorr
adorr / sessionconcurrency
Created August 27, 2011 04:56
ruby session concurrency problem
class FoosController < ApplicationController
def zero
session[:zero] = "zero"
sleep 1
render :text => "zero: #{session[:zero]}<br/>one: #{session[:one]}<br/>two: #{session[:two]}
<br/>three: #{session[:three]}"
end
def one
session[:one] = "one"
Failures:
1) Phase validation upload_sizing: upload width and height are set, but thumbs are not set: only image uploads are enabled: only has a resize key
Failure/Error: @phase.upload_sizing.should == @expected
expected: {:resize=>{:width=>800, :height=>800}, :export=>{:use=>["resize", "resize_thumb"]}}
got: {:resize=>{:width=>800, :height=>800}, :export=>{:use=>["resize"]}} (using ==)
Diff:
@@ -1,3 +1,2 @@
-{:resize=>{:width=>800, :height=>800},
- :export=>{:use=>["resize", "resize_thumb"]}}
def upload_sizing
result = {:export => {use: []}}
return result unless self.uploads_enabled?
if self.upload_width? && self.upload_height?
if self.enable_images?
result[:resize] = {