Skip to content

Instantly share code, notes, and snippets.

View pantras's full-sized avatar

Philippe Antras pantras

  • Sophia Antipolis
View GitHub Profile
@MilanGrubnic70
MilanGrubnic70 / puts_print_p.md
Last active June 13, 2022 19:22
puts vs. print vs. p

#puts vs. print vs. p ###The 'puts' (short for "put string") and 'print' commands are both used to display the results of evaluating Ruby code. ###Both 'puts' and 'print' call the 'to_s' method on the object AND return nil.

###The primary difference between them is that 'puts' adds a newline after executing, and 'print' does not. ###They don't RETURN anything so the RETURN value is nil. ###Using 'p' calls the 'inspect' method on the object.

print "Milan"
Milan => nil

@iboard
iboard / ruby-destructor-example.rb
Last active February 12, 2022 13:54
Ruby 'Destructor' example.
class Foo
attr_reader :bar
def initialize
@bar = 123
ObjectSpace.define_finalizer( self, self.class.finalize(bar) )
end
def self.finalize(bar)
proc { puts "DESTROY OBJECT #{bar}" }
end
@ilude
ilude / test-ssl-cipher.sh
Created March 2, 2012 18:10
Test https ssl ciphers
#!/bin/bash
# OpenSSL requires the port number.
SERVER=localhost:443
DELAY=1
echo -n Testing ssl2...
result=$(echo -n | openssl s_client -ssl2 -connect $SERVER 2>&1)
if [[ "$result" =~ "Cipher :" ]] ; then
echo supported. INSECURE!
#!/bin/bash
#
# git-svn-diff originally by (http://mojodna.net/2009/02/24/my-work-git-workflow.html)
# modified by mike@mikepearce.net
# modified by aconway@[redacted] - handle diffs that introduce new files
# modified by t.broyer@ltgt.net - fixes diffs that introduce new files
# modified by m@rkj.me - fix sed syntax issue in OS X
#
# Generate an SVN-compatible diff against the tip of the tracking branch
@ahoward
ahoward / net-http-debug.rb
Created December 10, 2010 20:06
a simple way to debug tons of libs that use ruby's net/http
BEGIN {
require 'net/http'
Net::HTTP.module_eval do
alias_method '__initialize__', 'initialize'
def initialize(*args,&block)
__initialize__(*args, &block)