Skip to content

Instantly share code, notes, and snippets.

@elvuel
elvuel / oauth.rb
Created April 10, 2012 03:50 — forked from robertsosinski/oauth.rb
Step-by-step processes of creating an OAuth Authorization Header
require 'uri'
require 'base64'
require 'openssl'
# NOTE: Oauth uses a specific unreserved character list for URL encoding.
def url_encode(input)
unreserved = '-._~0-9A-Za-z' # These are the only characters that should not be encoded.
URI.escape(input, Regexp.new("[^#{unreserved}]"))
end
@elvuel
elvuel / gist:2419978
Created April 19, 2012 09:39 — forked from jinie/gist:1065394
Read binary file in ruby and print hex output
#!/usr/bin/ruby
require 'getoptlong'
filename = ""
blocksize = 1024
opts = GetoptLong.new(
[ "-f", "--file", GetoptLong::REQUIRED_ARGUMENT],
[ "-b", "--block", GetoptLong::REQUIRED_ARGUMENT]
@elvuel
elvuel / ejabberd_auth.rb
Created April 25, 2012 02:21 — forked from abloom/ejabberd_auth.rb
ejabberd auth external script
#!/usr/bin/env ruby
require 'logger'
$stdout.sync = true
$stdin.sync = true
path = "/usr/local/var/log/ejabberd/auth.log"
file = File.open(path, File::WRONLY | File::APPEND | File::CREAT)
file.sync = true
#!/usr/bin/env ruby
require 'logger'
require 'rest_client'
$stdout.sync = true
$stdin.sync = true
path = "/usr/local/var/log/ejabberd/auth.log"
file = File.open(path, File::WRONLY | File::APPEND | File::CREAT)
@elvuel
elvuel / app.build.js
Created May 9, 2012 03:06 — forked from Integralist/app.build.js
RequireJs Build Script
/*
* http://requirejs.org/docs/optimization.html
*
* Use NodeJs to execute the r.js optimization script on this build script
* node r.js -o app.build.js
*
* See: https://github.com/jrburke/r.js/blob/master/build/example.build.js for an example build script
*
* If you specify just the name (with no includes/excludes) then all modules are combined into the "main" file.
* You can include/exclude specific modules though if needed
({
baseUrl: "../js",
mainConfigFile: "../js/main.js",
optimize: "none",
name: "main",
//excludeShallow: ["jquery", "handlebars", "leaflet", "wax"],
out: "../js/main-built.js",
paths: {
jquery: 'empty:',
@elvuel
elvuel / 01-tmpl.js
Created May 9, 2012 03:15 — forked from SlexAxton/01-tmpl.js
tmpl requirejs plugin
// START Handlebars
var Handlebars = {
precompile: function(){},
compile : function(){},
template : function(){}
};
define( 'Handlebars', [], function(){
return Handlebars;
});
@elvuel
elvuel / v1.html
Created May 9, 2012 06:37
bootstrap_modal_v1_v2
<body>
<div class="divDemoBody">
<h1>Bootstrap Modal Demo</h1>
<p><a href="http://scripting.com/stories/2012/01/11/bootstrapModalDemo.html">A simple demo</a> of a modal dialog in <a href="http://twitter.github.com/bootstrap/">Bootstrap</a>.</p><p>1. Click the button. 2. Enter a new title for the window. 3. Click OK.</p><p>We set the title of the window and close the dialog.</p>
<div id="windowTitleDialog" class="modal hide fade">
<div class="modal-header">
<a href="#" class="close">×</a>
<h3>Please enter a new title for this window.</h3>
</div>
<div class="modal-body">
modules:
- name: 'common_libs'
exclude: ['jquery']
- name: 'application'
exclude: ['jquery', 'common_libs']
- name: 'common'
exclude: ['jquery', 'common_libs']
paths:
jquery: 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min'
jqueryui: 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.19/jquery-ui.min'
modules:
- name: 'common_libs'
exclude: ['jquery']
- name: 'application'
exclude: ['jquery', 'common_libs']
- name: 'common'
exclude: ['jquery', 'common_libs']
paths:
jquery: 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min'
jqueryui: 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.19/jquery-ui.min'