Skip to content

Instantly share code, notes, and snippets.

View nacx's full-sized avatar

Ignasi Barrera nacx

View GitHub Profile
@nacx
nacx / go_cpu_memory_profiling_benchmarks.sh
Created May 25, 2021 07:57 — forked from arsham/go_cpu_memory_profiling_benchmarks.sh
Go cpu and memory profiling benchmarks. #golang #benchmark
go test -run=. -bench=. -benchtime=5s -count 5 -benchmem -cpuprofile=cpu.out -memprofile=mem.out -trace=trace.out ./package | tee bench.txt
go tool pprof -http :8080 cpu.out
go tool pprof -http :8081 mem.out
go tool trace trace.out
go tool pprof $FILENAME.test cpu.out
# (pprof) list <func name>
# go get -u golang.org/x/perf/cmd/benchstat
benchstat bench.txt
@nacx
nacx / provision-tenant.py
Last active August 11, 2017 12:34
Script to provision a tenant in Abiquo and create an initial virtual datacenter
#!/usr/bin/env python
# Python script to provision a tenant.
#
# It uses the Abiquo API python bindings. It can be installed as follows:
# $ virtualenv /opt/abiquo
# $ source /opt/abiquo/bin/activate
# $ pip install abiquo-api
import json
@nacx
nacx / azure-arm.diff
Last active September 20, 2016 10:28
diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeProviderMetadata.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeProviderMetadata.java
index 460df67..5c5a6ae 100644
--- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeProviderMetadata.java
+++ b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeProviderMetadata.java
@@ -17,31 +17,30 @@
package org.jclouds.azurecompute.arm;
+import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.DEFAULT_DATADISKSIZE;
+import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.DEFAULT_IMAGE_LOGIN;
@nacx
nacx / Overlap.java
Last active March 22, 2024 17:32
Network overlapping check
private static boolean overlap(final String net1, final String net2)
{
SubnetInfo subnet1 = new SubnetUtils(net1).getInfo();
SubnetInfo subnet2 = new SubnetUtils(net2).getInfo();
int mask1 = subnet1.asInteger(subnet1.getNetmask());
int mask2 = subnet2.asInteger(subnet2.getNetmask());
int maskToUse = mask1 < mask2 ? mask1 : mask2;
int addr1 = subnet1.asInteger(subnet1.getAddress()) & maskToUse;
@nacx
nacx / expected.rb
Last active May 2, 2016 15:17
Chef resource dynamic notification
# This has the intended behavior, but I need to declare the log[bar] at the end
log "bar" do
action :nothing
end
log "foo" do
begin
notifies :write, resources("log[bar]").to_s, :immediately
rescue Chef::Exceptions::ResourceNotFound
@nacx
nacx / .classpath
Created January 20, 2016 15:56
jclouds compute-basics Eclipse config
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER" />
<classpathentry kind="output" path="target/classes"/>
</classpath>
@nacx
nacx / chefspec-failure
Created December 11, 2014 10:36
ChefSpec failure
$ rspec spec/default_spec.rb
DL is deprecated, please use Fiddle
/home/ibarrera/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chef-12.0.1/lib/chef/resource/file.rb:29:in `<class:File>': undefined method `identity_attr' for Chef::Resource::File:Class (NoMethodError)
from /home/ibarrera/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chef-12.0.1/lib/chef/resource/file.rb:26:in `<class:Resource>'
from /home/ibarrera/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chef-12.0.1/lib/chef/resource/file.rb:25:in `<class:Chef>'
from /home/ibarrera/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chef-12.0.1/lib/chef/resource/file.rb:24:in `<top (required)>'
from /home/ibarrera/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from /home/ibarrera/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from /home/ibarrera/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/chef-12.0.1/lib/chef/provider/file.rb:22:in
With Chef 12
------------
$ chef-apply subscribes.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
* log[subscribed-log] action nothing (skipped due to action :nothing)
* yum_package[nano] action install
- install version 2.0.9-7.el6 of package nano
(Note that the logger has not been triggered after installing the package
@nacx
nacx / inverse-cidr.py
Created October 10, 2014 08:12
Compute the inverse list of CIDR blocks
"""Use it like this: main('192.168.1.0/24')"""
IPV4_MIN = 0
IPV4_MAX = 0xFFFFFFFF
def not_network(ipv4_address, ipv4_netmask):
assert IPV4_MIN <= ipv4_address <= IPV4_MAX
assert IPV4_MIN <= ipv4_netmask <= IPV4_MAX
def hostmask_netmask(m):
@nacx
nacx / keybase.md
Created August 18, 2014 09:01
keybase.md

Keybase proof

I hereby claim:

  • I am nacx on github.
  • I am nacx (https://keybase.io/nacx) on keybase.
  • I have a public key whose fingerprint is 8734 E018 56BC 8307 CD94 AC2E 3D54 14A0 D959 B94F

To claim this, I am signing this object: