Skip to content

Instantly share code, notes, and snippets.

View jsrois's full-sized avatar

Javier Sánchez Rois jsrois

View GitHub Profile
@jsrois
jsrois / polymorphism-plus-unique-ptr.cpp
Created April 3, 2017 12:17
How can we create an std::vector for objects implementing an interface?
#include <iostream>
#include <vector>
#include <memory>
#include <sstream>
using namespace std;
struct RuleImpl {
virtual string serialize() const = 0;
};
#!/bin/bash
if [ "$#" -ge 1 ]; then
first_commit=$1
else
first_commit=HEAD^
echo "Analyzing last commit only"
fi
for commit in $(git log $first_commit..HEAD --pretty=format:"%h") ; do
@jsrois
jsrois / install_caffe_sunai_uoc.sh
Last active August 31, 2016 17:06
Installs Caffe in the Sunai@UOC server (May2016)
git clone https://github.com/BVLC/caffe.git
mkdir caffe/build
cd caffe/build
# these two hacks are required
export LC_ALL=es_ES.UTF-8 # this locale variable is unset
sed -i '29iset(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FORCE_INLINES")' ../CMakeLists.txt
cmake -DBUILD_matlab=ON .. # matlab is disabled by default
make all # this takes a while
make runtest # all green
cd -
#!/bin/bash
domain_name=example.com
date_info=$(date +%s)
output_file=add_users_$date_info.groovy
echo "// Automatically generated groovy script -- $date_info" > $output_file
while [[ $# > 0 ]]
do
echo "generating user/password for [$1]..."
pass=$(date +%s | sha256sum | base64 | head -c 32 ; echo)
user=$1
#!/bin/sh
set -e
set -x
temp_dir=/tmp/install_consolas_and_solarized
mkdir -p $temp_dir
sudo apt-get install cabextract -y
pushd $temp_dir
echo "installing consolas"
wget http://download.microsoft.com/download/E/6/7/E675FFFC-2A6D-4AB0-B3EB-27C9F8C8F696/PowerPointViewer.exe
cabextract -L -F ppviewer.cab PowerPointViewer.exe
@jsrois
jsrois / copyFiles.pri
Created July 29, 2015 10:27
function used to copy target files to an specific location
defineTest(copyFiles) {
files = $$1 # first argument is a list of files
DDIR = $$2 # second is a destination directory
# first we create the destination dir
QMAKE_POST_LINK += $$QMAKE_MKDIR $$quote($$DDIR) $$escape_expand(\\n\\t)
# second we copy 'em files
for(FILE, files) {
# Replace slashes in paths with backslashes for Windows
#=Navigating=
visit('/projects')
visit(post_comments_path(post))
#=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click_on('Button Value')