This file contains hidden or 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 "rubygems" | |
require 'RMagick' | |
include Magick | |
## Image that you want to resize | |
img = ImageList.new(File.join(Rails.root,'public',self.logo_image.to_s)) | |
## Resize Parameter | |
img.resize!(self.logo_width.to_i, self.logo_height.to_i) | |
## Resize to filed name you want to use | |
img.write(File.join(Rails.root,'public',self.logo_image.to_s)) |
This file contains hidden or 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 "rubygems" | |
require "net/http" | |
require "open-uri" | |
require "fileutils" | |
## BASE_DIR where the file will be stored | |
BASE_DIR = "" | |
def open_url(url) | |
begin | |
url = File.join(BASE_PATH,url) |
This file contains hidden or 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
> - In ruby 1.8.x, what is the functional difference between rb_thread_schedule and rb_thread_select? | |
rb_thread_schedule() is the guts of the thread scheduler, it traverses | |
over the linked list of threads (several times) to find the next one | |
to switch into. The function is long (250 lines) and messy, and covers | |
all the combinations of thread status (RUNNABLE, TO_KILL, STOPPED, | |
KILLED) and wait state (FD, SELECT, TIME, JOIN, PID). | |
If there are no threads doing i/o or waiting on a timeout, | |
rb_thread_schedule() picks another thread from the list (considering |
This file contains hidden or 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
Rails.configuration.middleware.use RailsWarden::Manager do |manager| | |
manager.default_strategies :api_authentication | |
## Write a failure app | |
manager.failure_app = CustomFailureApp #Proc.new { |env| ['200',{'Content-Type' => 'text/html'},['Logout You Idiot']] } | |
end | |
Warden::Strategies.add(:api_authentication) do | |
def valid? | |
params[:user] and (params[:user][:email] || params[:user][:password]) |
This file contains hidden or 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
$('body').on('click','.deleteFacadeButton',function() { | |
var checkedVal = $('#deleteAssocShareatives').is(':checked'); | |
deleteFacade(facadeIdToDelete, checkedVal); | |
$('#show-all-facades').trigger('click'); | |
hideModal($('#deleteFacadeModal')); | |
}) | |
// Deleting a Facade FIXME - remove the inner event outside | |
$('body').on('click', '.facadeDelete', function(event){ |
This file contains hidden or 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
tell application "SystemUIServer" | |
set actionSelected to the button returned of (display dialog "What you want to do?" buttons {"Send file", "Receive file"} default button 2) | |
if actionSelected = "Send file" then | |
set filepath to POSIX path of (choose file) | |
display dialog "Please enter IP address of receiver:" default answer "" | |
set ipAddress to text returned of result | |
if ipAddress = "" then | |
repeat | |
display dialog "IP address cant be blank,Please enter IP address of receiver:" default answer "" |
This file contains hidden or 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 'rubygems' | |
require 'json-schema' | |
## /poaster_instance.json | |
## Seem like the need to have access_control a part of this json | |
poaster_instance_schema = { | |
"type" => "object", | |
"required" => ['id','facades','name'], | |
"properties" => { | |
"id" => {"type" => "string"}, | |
"name" => {"type" => "string"}, |
This file contains hidden or 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
... | |
... | |
... | |
use Warden::Manager | |
use Rack::Mongoid::Middleware::IdentityMap | |
use ExceptionNotifier | |
use OmniAuthMiddleware ## <-- | |
use OmniAuth::Builder | |
run MyAppliction::Application.routes |
This file contains hidden or 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 'celluloid/zmq' | |
Celluloid::ZMQ.init | |
class Client | |
include Celluloid::ZMQ | |
def initialize | |
@socket = Socket::Push.new | |
begin |
This file contains hidden or 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 'celluloid/zmq' | |
Celluloid::ZMQ.init | |
class Client | |
include Celluloid::ZMQ | |
def initialize | |
@socket = Socket::Push.new | |
begin |
OlderNewer