Skip to content

Instantly share code, notes, and snippets.

View vguerra's full-sized avatar
💭
🏂

Victor Guerra vguerra

💭
🏂
View GitHub Profile
@vguerra
vguerra / gist:10426226
Created April 10, 2014 21:43
multicolumn summary - SquareSpace
<script type='text/javascript'>
YUI().use('node', 'event-base', function (Y) {
Y.on('domready', function () {
Y.all('.summary-block').each(
function () {
// 4 -> 3 cols
// 3 -> 4 cols
// 6 -> 2 cols
Y.all('.summary-item', this).wrap('<div class="col sqs-col-4 span-4"></div>');
Y.all('.col > .summary-item').wrap('<div class="newSummary"></div>');
@vguerra
vguerra / gist:c94c77b4f155d73d8f47
Last active August 29, 2015 14:00
xotcl-core ::xo::dc database context

Xotcl Core Database Context Objects

Recently, there has been a new addition in xotcl-core that allows to have different database contexts to interact with the database. At run time, one can dynamically change the interface one wants to talk to the DB with. This allows us to operate simultaneously with two db interfaces talking to the same database: nsdb (nsdbpg ) and nsdbi (nsdbipg). The reasons we want to have such a setup are the following:

  • First of all, giving the way nsdbpgi is implemented, queries run sometimes up to 10 times faster through that interface. Therefore we want to be able to use this interface to run our queries. The following tests show how fast it is:
# dbi_* calls beling to the nsdbi interface and db_* calls to the nsdb one.
append _ [time {dbi_rows  {select object_id from acs_objects limit 200}} 100]
append _ [time {dbi_rows {select object_id, title from acs_objects limit 200}} 100]
@vguerra
vguerra / gist:83e38ed0a9275af08d7c
Created May 3, 2014 01:28
using pkg-config to query information about nanomsg
diff --git a/wscript b/wscript
index fe8cfb7..3b403a1 100755
--- a/wscript
+++ b/wscript
@@ -43,7 +43,7 @@ DEFAULT_CONF = {
def build_nanomsgext(waf):
conf = copy(DEFAULT_CONF)
conf.update({
- 'lib' : ['nanomsg'],
+ 'use' : ['NANOMSG'],
@vguerra
vguerra / gist:ad50cf2e2102b725b133
Last active August 29, 2015 14:06
Ordered insertion into a vector: using learn search vs. binary search
// Victor Guerra <vguerra@gmail.com>
// 2014-09-26
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
@vguerra
vguerra / gist:53b03d589ecdbd93d31f
Created October 2, 2014 10:04
Eliminating branches with templates
#include <iostream>
#include <string>
template <bool B>
void Log(std::ostream& out, const std::string& str) {
if (B) {
out << str << "\n";
}
@vguerra
vguerra / gist:2700a655499e510e9067
Created October 30, 2014 14:10
Modifying variables out of function scope via the stack
#include <stdio.h>
int fun() {
int a = 1;
int *p = &a;
while (*p != 10) {p++;}
*p = 30;
return 0;
}
@vguerra
vguerra / gist:11d13b572edd46816af0
Created March 9, 2015 10:46
Commits count per author email
git log --format=%ae |sort | uniq -c| sort -nr| less
@vguerra
vguerra / gist:fee51b92f3da901a147d
Created April 27, 2015 15:24
cvs merging back changes for openacs from a given branch
# Example using oacs-5-8 branch.
# tag first the desired branch
cvs checkout -r oacs-5-8 openacs-4
cd openacs-4
cvs tag -F vg-merge-oacs-5-8-date
# you can update the current checkout with
cvs up -A
@vguerra
vguerra / gist:2709857
Created May 16, 2012 12:06
building nsf breaks when dtrace is not installed ( even when --with-dtrace was not used when configuring ).
diff --git a/Makefile.in b/Makefile.in
index c587962..0774957 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -78,8 +78,8 @@ mkinstalldirs= mkdir -p
#========================================================================
DTRACE_OBJ = @DTRACE_OBJ@
-DTRACE_HDR = $(src_generic_dir)/nsfDTrace.h
-DTRACE_SRC = $(src_generic_dir)/nsfDTrace.d
@vguerra
vguerra / gist:2774209
Created May 23, 2012 09:27
Collecting stats
#!/bin/sh
i=0
while [ $i -lt 1 ]
do
sleep 5
wget -q -O - tlftest.wu.ac.at:8000/stats
echo ""
done