Skip to content

Instantly share code, notes, and snippets.

View aibrahim's full-sized avatar

Abdullah Mansour aibrahim

View GitHub Profile
@aibrahim
aibrahim / e
Created April 28, 2014 15:56
compute Euler number e
#include <stdio.h>
/*get factorial of n*/
double fact(int n);
/* invoke seq to get e */
double gete(int n);
int
main(int argc, char *argv[])
require 'socket' # Get sockets from stdlib
server = TCPServer.open(17010) # Socket to listen on port 2000
loop { # Servers run forever
Thread.start(server.accept) do |client| # Wait for a client to connect
authmethod = client.gets
if authmethod.strip == "none"
client.puts "i'm Empty String"
client.puts `sh`
@aibrahim
aibrahim / cpu
Created December 22, 2010 12:26
authmethod = ARGV[0]
server = ARGV[1]
port = 17010
s = TCPSocket.open(server, port)
if authmethod == "none"
s.puts "none"
while line = s.gets
puts line
end
the \0 means a zero byte.
client->server: "authmethod params"\0
client sends the auth method and auth method specific
parameters. for us, we only care if authmethod
is "none" and ignore the params.
server->client: ""\0
we reply with empty string if authentification was successfull
(authmethod=="none")
respond_to do |format|
if verify_recaptcha(:model => @product, :notice => "error with reCAPTCHA!")
if @product.save
format.html { redirect_to(@product, :notice => 'Product was successfully created.') }
format.xml { render :xml => @product, :status => created, :location => @product }
else
format.html { render :action => "new" }
format.xml { render :xml => @product.errors, :status => :unprocessable_entity }
end
else
@aibrahim
aibrahim / error
Created March 29, 2011 14:48
i'm running my script with ruby1.8.7 in rvm
/home/visof/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/specification.rb:509:in `read': can't convert Hash into Integer (TypeError)
from /home/visof/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/specification.rb:509:in `load'
from /home/visof/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:116:in `load_gems_in'
from /home/visof/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:115:in `each'
from /home/visof/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:115:in `load_gems_in'
from /home/visof/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:112:in `reverse_each'
from /home/visof/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:112:in `load_gems_in'
from /home/visof/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:308:in `refresh!'
from /home/visof/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/sourc
File not found: lib
ERROR: While generating documentation for rails-3.0.5
... MESSAGE: exit
... RDOC args: --op /home/visof/.rvm/gems/ruby-1.8.7-p334@ruby187/doc/rails-3.0.5/rdoc --quiet lib --title rails-3.0.5 Documentation
(continuing with the rest of the installation)
Installing RDoc documentation for rake-0.8.7...
#!/home/visof/.rvm/rubies/ruby-1.8.7-p334/bin/ruby
require 'rexml/document'
include REXML
require 'rubygems'
require 'nokogiri'
require 'mechanize'
require 'open-uri'
require 'net/http'
require 'rexml/document'
*** LOCAL GEMS ***
actionmailer (2.3.5)
actionpack (2.3.5)
activemodel (3.0.5)
activerecord (2.3.5)
activeresource (2.3.5)
activesupport (3.0.5, 2.3.5)
arel (2.0.9)