Skip to content

Instantly share code, notes, and snippets.

View jsmpereira's full-sized avatar

José Santos Martins Pereira jsmpereira

  • Clearhaus A/S
  • Denmark
View GitHub Profile
require 'active_record'
# Migrating from http://github.com/tobi/delayed_job to http://github.com/collectiveidea/delayed_job
# and with some jobs pending resulted in execution failure due to handler format incompatibility.
#
# This rake task loops through your delayed_jobs table and updates the handler of each job to comply with
# collectiveidea's delayed_job.
#
# Hope this can be useful to someone.
#
@jsmpereira
jsmpereira / gist:1094024
Created July 19, 2011 23:46
Padrino pagination
#
# Adapted from http://pastebin.com/FL5KeQQH
#
# As mentioned on the link above put this on app/helpers/pagination.rb
# and you can use in your view
#
# =will_paginate @posts
#
# I'm also using this https://gist.github.com/837683
#
@jsmpereira
jsmpereira / gist:3763404
Created September 21, 2012 19:28
cl-inotify
(defun pickaxe (directory)
(inotify:with-inotify (inot `((,directory ,(logior inotify:in-create
inotify:in-moved-to))))
(write-line "Waiting for sales...")
(loop
(dolist (event (inotify:read-events inot))
(when (equal
(pathname-type (inotify:event-full-name event))
"xml")
(if (string-equal directory "/path/to/dropbox/")
;; DISCONNECT_REQ
(defun disconnect-req ()
(with-buffer (make-buffer)
(serialize* :uint8 27
:uint16 8
:uint16 32865
:uint16 29
:uint16 7))) ;; command code
@jsmpereira
jsmpereira / gist:3827894
Created October 3, 2012 16:09
heroku config/database.yml
<%
require 'cgi'
require 'uri'
begin
uri = URI.parse(ENV["DATABASE_URL"])
rescue URI::InvalidURIError
raise "Invalid DATABASE_URL"
end
$ heroku run bash
Running `bash` attached to terminal... up, run.1256
~ $ cd sbcl/sbcl-1.0.54-x86-64-linux/
~/sbcl/sbcl-1.0.54-x86-64-linux $ chmod +x run-sbcl.sh
~/sbcl/sbcl-1.0.54-x86-64-linux $ ./run-sbcl.sh
(running SBCL from: /app/sbcl/sbcl-1.0.54-x86-64-linux)
This is SBCL 1.0.54, an implementation of ANSI Common Lisp.
(defun build-matrix ()
(let* ((n-nodes (length (nodes)))
(dim `(,n-nodes ,n-nodes)))
(gsll:set-zero (grid:make-foreign-array 'double-float :dimensions dim))))
(defparameter *adj-matrix* nil)
(defparameter *diag-matrix* nil)
(defmacro with-matrix (matrix &body body)
`(loop for i below (first (grid:dimensions ,matrix)) do
Hi,
After trying out GSLL, Clem, also FemLisp, Lisplab managed to get me
the functionality I needed with the least trouble.
I'm trying to get the connectivity of a graph (second smallest eigen value) from eigenvalues.
Given the fully connected 4x4 adjacency matrix:
#md(( 0.000 1.000 1.000 1.000 )
(defparameter *world* nil)
(defclass tile ()
((x :initarg :x
:accessor x)
(y :initarg :y
:accessor y)
(size :initarg :size
:accessor size)
(color :initarg :color
/* The purpose of this program is to monitor routing
* table changes
*/
#include <sys/socket.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>