Skip to content

Instantly share code, notes, and snippets.

View tyler-smith's full-sized avatar

Tyler Smith tyler-smith

View GitHub Profile
@tyler-smith
tyler-smith / gist:3995724
Created November 1, 2012 18:57
Give a UserVoice suggestion 3 votes using the OAuth API
require 'uservoice-ruby'
SUBDOMAIN_NAME = 'your_subdomain'
API_KEY = 'your_key'
API_SECRET = 'your_secret'
URL = 'http://localhost:3000/'
client = UserVoice::Client.new(SUBDOMAIN_NAME, API_KEY, API_SECRET, :callback => URL)
user = '[email protected]'
forum_id = 12345
<?
// Your account info
$USERVOICE_SUBDOMAIN = 'your_subdomain';
$API_KEY = 'your_key';
$API_SECRET = 'your_secret';
// Info about the suggestion and user
$user = '[email protected]';
$forum_id = 1234;
@tyler-smith
tyler-smith / uservoice_vote.php
Created November 5, 2012 19:09
Set UserVoice Suggestion's vote with PHP API
<?php
$USERVOICE_SUBDOMAIN = '**SCRUBED**';
$SSO_KEY = '**SCRUBED**';
$API_KEY = '**SCRUBED**';
$API_SECRET = '**SCRUBED**';
// Use autoload.php of Composer to use the library and its dependencies:
require_once 'vendor/autoload.php';
1.9.3p286 :001 > a = Hash.new([])
=> {}
1.9.3p286 :002 > a[:foo] << 1
=> [1]
1.9.3p286 :003 > a[:bar] << 1
=> [1, 1]
1.9.3p286 :004 > b = Hash.new(){[]}
=> {}
1.9.3p286 :005 > b[:foo] << 1
=> [1]
# my machine
> curl https://secure.braintreepaymentgateway.com/api/query.php
> <?xml version="1.0" encoding="UTF-8"?>...
# web60
> curl https://secure.braintreepaymentgateway.com/api/query.php
> <?xml version="1.0" encoding="UTF-8"?>...
# chrome (requesting url manually)
<?xml version="1.0" encoding="UTF-8"?>...
<script src='/sample.js'></script>
<script>
window.my_func('hello, world!');
</script>
tyler@~/dev/work/uservoice> cap deploy production:rollback
triggering start callbacks for `deploy'
* == Currently executing `multistage:ensure'
*** Defaulting to `staging'
* == Currently executing `staging'
* == Currently executing `deploy'
"xxxxxxxx".force_encoding('utf-8') == "xxxxxxxx".force_encoding('ASCII-8BIT') #=> true
"\xc3\xa9".force_encoding('utf-8') == "\xc3\xa9".force_encoding('ASCII-8BIT') #=> false
"\xc3\xa9".force_encoding('utf-8') == "\xc3\xa9".force_encoding('utf-8') #=> true
int
rb_str_cmp(VALUE str1, VALUE str2)
{
long len1, len2;
const char *ptr1, *ptr2;
int retval;
if (str1 == str2) return 0;
RSTRING_GETMEM(str1, ptr1, len1);
RSTRING_GETMEM(str2, ptr2, len2);
1.9.3p286 :005 > a = 'a'
=> "a"
1.9.3p286 :006 > b = [a.method(:to_i), a.method(:upcase)]
=> [#<Method: String#to_i>, #<Method: String#upcase>]
1.9.3p286 :007 > b[1].call
=> "A"