Skip to content

Instantly share code, notes, and snippets.

View nauman's full-sized avatar
🚀
Need MVP? book me in https://tidycal.com/nauman

Nauman Tariq nauman

🚀
Need MVP? book me in https://tidycal.com/nauman
View GitHub Profile
@nauman
nauman / common.rb
Created July 16, 2012 01:59
Common VCR testing
require 'vcr'
require 'addressable/uri'
require 'net/http'
require 'uri'
VCR.configure do |configure|
configure.cassette_library_dir = File.join(File.dirname(__FILE__), 'fixtures')
configure.hook_into :webmock
#1. Change request before http request
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
require 'tests/drivers/fgcp/common'
require 'rubygems'
describe 'Deltacloud API' do
include Deltacloud::Test
it 'must returns valid drivers' do
get collection_url(:drivers)
last_response.status.must_equal 200
ENV['API_DRIVER'] = 'fgcp'
ENV['API_USERNAME'] = 'cert-dir'
ENV['API_PASSWORD'] = 'password'
load File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'deltacloud_rack.rb')
#load File.join(File.dirname(__FILE__), '..', '..', 'common.rb')
Deltacloud::configure do |server|
server.root_url '/api'
server.version '0.5.0'
fgcp_type = ProviderType.find_by_name('fgcp')
# Create a Username credential definition
CredentialDefinition.create!({
:name => 'username',
:label => 'Username',
:input_type => 'text',
:provider_type => fgcp_type
})
@nauman
nauman / ssltest.rb
Created April 18, 2012 03:20
openssl will work on windows with this code as well for pk12 type
#!/usr/bin/ruby
require 'openssl'
require 'base64'
if ARGV.length == 2
pkcs12 = OpenSSL::PKCS12.new(File.read(ARGV[0]), ARGV[1])
p pkcs12.certificate
else
puts "Usage: load_cert.rb <path_to_cert> <cert_password>"
end
<?php
$precision = 49;
ini_set("precision", $precision);
echo pi(); //will output 3.141592653589793115997963468544185161590576171875
?>
<?php
//static variable make place in memory without initialization the object\
//static functions are class level function not object level, they cant access object level
class YourClass
{
protected $_attribute;
public function __construct() {
$this-> _attribute = 10;
<?php
class Sentence{
static $phrase = "";
static $word1 = "eek";
static $word2 = "eep";
static $word3 = "yikis";
static function callRecursive($x){
//print $x."\n"; checking counter