This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Moose; | |
my $meta = Moose::Meta::Class->create_anon_class(); | |
$meta->add_attribute("foo" => (is => "rw", isa => "Int")); | |
$meta->make_immutable; | |
my $object = $meta->new_object(foo => 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
/* | |
Example of creating go routine with time based channel - this time can be | |
adjusted by the parent, so it can postpone (or bring forwards) whatever the | |
child should do. This could be useful for creating a polling mechanism which | |
you occasionally want to run sooner. | |
The parent creates the channel and passes it to the go routine to wait for 10 | |
seconds. This channel is used to communicate how long the child should wait |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
// This function returns a function that returns the current time. The current | |
// time is only updated when the returned function is called, and at most once | |
// during every period |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(comment (defproject otrs "0.1.0-SNAPSHOT" | |
:description "Example of Shibboleth login to OTRS with htmlunit" | |
:url "http://example.com/FIXME" | |
:license {:name "Eclipse Public License" | |
:url "http://www.eclipse.org/legal/epl-v10.html"} | |
:dependencies [[org.clojure/clojure "1.6.0"] | |
[net.sourceforge.htmlunit/htmlunit "2.15"]])) | |
(ns otrs.core | |
(:import (com.gargoylesoftware.htmlunit WebClient))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Net::SSLeay qw(get_peer_certificate); | |
use Net::LDAP; | |
my $ldap = Net::LDAP->new("ldap.fe.up.pt") or die $!; | |
$ldap->start_tls or die $!; | |
$ldap->bind or die $!; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns user | |
(:require [liberator core representation] | |
[ring.middleware params session flash] | |
[ring.mock.request])) | |
;; Return HTTP 303 - have to manage Location ourselves | |
((-> | |
(liberator.core/resource | |
:available-media-types ["text/html" "application/x-www-form-urlencoded"] | |
:allowed-methods [:get :post] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn freq2leaves | |
"Convert a sequence of symbols and their frequency into a sequence of hash-maps with keys :sym :freq" | |
[xs] (map #(hash-map :sym (first %) :freq (second %)) xs)) | |
(defn huffman | |
"Perform Huffman encoding for the sequence xs of hash maps from freq1leaves. | |
Return tree of hash-maps with keys :freq and either :symbol (when a leaf) or | |
:children (when an internal node). :children is a vector of the child nodes." | |
[xs] | |
(letfn [(sort-queue [xs] (sort #(compare (:freq %1) (:freq %2)) xs)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# Simple (!) Net::DBus service example using AnyEvent::DBus to run the event | |
# loop. You can examine the service with the following command: | |
# gdbus introspect --session --dest=pt.up.fe.door -o /pt/up/fe/door | |
# | |
# And invoke the unlock method as follows: | |
# dbus-send --session --dest=pt.up.fe.door /pt/up/fe/door pt.up.fe.door.unlock | |
# | |
# Once the unlock method is invoked, the program terminates. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# Make call when program receives SIGHUP, hangup when call is answered | |
use strict; | |
use warnings; | |
use 5.10.0; | |
use Net::SIP 0.687; | |
#use Net::SIP::Debug 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import ovs.db.idl | |
import ovs.poller | |
ovs.vlog.Vlog.set_levels_from_string("console:dbg") | |
ovs.vlog.Vlog.init() | |
remote = 'unix:/var/run/openvswitch/db.sock' | |
# If not present, will read from default path |
OlderNewer