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
var LDAPConnection = require("LDAP").Connection; | |
var LDAP = new LDAPConnection(); | |
if (LDAP.open("ldap://localhost", 3) < 0) { | |
throw new Error("Unable to connect to server"); | |
} | |
LDAP.simpleBind("cn=bigshot,dc=test,dc=com","opensesame",function(msgid,err){ | |
if(err) | |
console.log(err); |
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
require 'rubygems' | |
require 'ldap' #gem ruby-ldap | |
conn = LDAP::Conn.new('localhost', 389) | |
conn.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION,3) | |
r = conn.bind "cn=bigshot,dc=test,dc=com","opensesame" | |
puts r.inspect |
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
require 'fcntl' | |
require 'eventmachine' | |
#what is needed | |
#mkfifo mypipe | |
#that everything written thru the pipe have a "\n" | |
#ex: echo "foobar\n" > mypipe | |
#HPO = Handle Pipe Output | |
module HPO |
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
require 'ostruct' | |
require 'benchmark' | |
net_objs = [] | |
class NetworkObject < OpenStruct | |
· | |
end | |
0.upto(1000) { |n| net_objs.push NetworkObject.new(:name=>"foo #{n}",:removed=>[true,false].sample) }· |
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
class Author < ActiveRecord::Base | |
has_many :books | |
end | |
class Book < ActiveRecord::Base | |
belongs_to :author | |
include Tire::Model::Search | |
include Tire::Model::Callbacks | |
mapping do | |
indexes :title, |
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
#!/bin/bash | |
# Basic QoS script that uses OpenDPI (http://www.opendpi.org/) | |
# Netfilter wrapper to identify packets by the protocol. | |
# | |
# This script enqueues packets in three queues, each one | |
# with a different priority: | |
# | |
# The first queue has the higher priority and gets the TCP SYN | |
# packets, ACKs, ICMPs and packets with Minimize-Delay TOS. |
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
class Foo | |
include Mongoid::Document | |
field :enabled, :type=>Boolean, :default=>false | |
scope :on, where(:enabled=>true) | |
scope :off, where(:enabled=>false) | |
end | |
irb> Foo.on.count | |
0 |
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
sp_censo2010 <- read.csv("~/R/sp_censo2010.csv", header=T, skip=2, dec=",",fileEncoding="ISO-8859-1", nrows=64) |
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
library('stringer') # probably you will have to install it with install.packages('stringer') | |
mulheres = subset(sp_censo2010,str_detect(sp_censo2010$Unidade,"mulheres")) | |
homens = subset(sp_censo2010,str_detect(sp_censo2010$Unidade,"homens")) |
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
class(homens$Valor) | |
[1] "factor" | |
as.numeric(as.character(homens$Valor)) | |
[1] 53 51 47 61 19 31 42 36 45 50 44 39 30 24 22 15 12 7 64 59 35 11 56 6 16 |
OlderNewer