Skip to content

Instantly share code, notes, and snippets.

@evanphx
evanphx / gist:6942344
Created October 11, 2013 21:30
Weird vagrant error
OUT: [default] Clearing any previously set network interfaces...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["hostonlyif", "ipconfig", "dyld: DYLD_ environment variables being ignored because main executable (/Applications/VirtualBox.app/Contents/MacOS/VBoxNetAdp", "--ip", "198.51.100.1", "--netmask", "255.255.255.0"]
Stderr: VBoxManage: error: The host network interface with the given name could not be found
VBoxManage: error: Details: code NS_ERROR_INVALID_ARG (0x80070057), component Host, interface IHost, callee nsISupports
VBoxManage: error: Context: "FindHostNetworkInterfaceByName(name.raw(), hif.asOutParam())" at line 220 of file VBoxManageHostonly.cpp
VBoxManage: error: Could not find interface 'dyld: DYLD_ environment variables being ignored because main executable (/Applications/VirtualBox.app/Contents/MacOS/VBoxNetAdp'
#!/usr/bin/env ruby -w
require "benchmark"
require 'benchmark/ips'
ARRAY = (1..1_000).to_a
Benchmark.ips do |b|
b.report "each" do
ARRAY.each do |element|
end
blah/java java 3ceadcb64ace 12 minutes ago 232.5 MB (virtual 364.3 MB)
blah/base precise 70178787e65f 47 minutes ago 131.8 MB (virtual 131.8 MB)
ubuntu 12.04 8dbd9e392a96 4 months ago 131.5 MB (virtual 131.5 MB)
ubuntu 12.10 b750fe79269d 4 months ago 24.65 kB (virtual 180.1 MB)
ubuntu latest 8dbd9e392a96 4 months ago 131.5 MB (virtual 131.5 MB)
ubuntu precise 8dbd9e392a96 4 months ago 131.5 MB (virtual 131.5 MB)
ubuntu quantal b750fe79269d 4 months ago 24.65 kB (virtual 180.1 MB)
<none> <none> 27cf78414709 4 months ago 180.1 MB (virtual 180.1 MB)
class Minutes
def initialize(count)
@count = count
end
def to_i
@count
end
def +(o)
struct cont {
int (*func)(int);
};
int work(int x) {
return x + 2;
}
int direct(int x) {
return work(x);
r, w = IO.pipe
t = Thread.new { puts "start"; IO.select([r]); puts "alive" }
sleep 1
Process.daemon true, true
puts Process.pid
t.join
puts "done"
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index ad2ec26..d468393 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -181,7 +181,12 @@ module Gem
# require will try to activate the more specific version.
spec = Gem::Specification.find_inactive_by_path path
- return false unless spec
+
require 'rack/util/file'
path = ARGV.shift || Dir.pwd
run Rack::File.new(path, { 'Accept-Ranges' => 'bytes'})
@evanphx
evanphx / a_std_func_overhead.cpp
Last active December 18, 2015 10:19
The cost of std::function
#include <functional>
extern void run(std::function<int(int)> f);
void foo() {
auto l = [](int x) { return x + 1; };
run(l);
}
@evanphx
evanphx / gist:5616248
Created May 20, 2013 22:55
qemu crash CLI
/usr/bin/kvm -name instance-000011dd -S -M pc-1.0 -cpu core2duo,+lahf_lm,+rdtscp,+pdpe1gb,+avx,+osxsave,+xsave,+aes,+tsc-deadline,+popcnt,+x2apic,+sse4.2,+sse4.1,+dca,+pdcm,+xtpr,+cx16,+tm2,+est,+smx,+vmx,+ds_cpl,+dtes64,+pclmuldq,+pbe,+tm,+ht,+ss,+acpi,+ds -enable-kvm -m 4096 -smp 1,sockets=1,cores=1,threads=1 -uuid 60a6d783-3be1-4522-ac30-fc22727eb868 -nodefconfig -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/instance-000011dd.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc,driftfix=slew -no-kvm-pit-reinjection -no-shutdown -kernel /var/lib/nova/instances/instance-000011dd/kernel -initrd /var/lib/nova/instances/instance-000011dd/ramdisk -append root=/dev/vda console=ttyS0 -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/var/lib/nova/instances/instance-000011dd/disk,if=none,id=drive-virtio-disk0,format=qcow2,cache=none -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -netdev ta