Skip to content

Instantly share code, notes, and snippets.

@weirdbricks
weirdbricks / threadbeast.rb
Created December 27, 2011 02:08
Thread Beast
#!/usr/bin/env ruby
require "rubygems"
require "sequel"
entries=0;entries=ARGV[0].to_i
threads=0;threads=ARGV[1].to_i
if ( entries.zero? || threads.zero? )
puts "Usage: ./tester number_of_entries number of threads\nValues cannot be 0"
exit
end
@weirdbricks
weirdbricks / uploadftptls.rb
Created January 16, 2012 05:39
upload to ftp/tls
this will upload a file on ftp using TLS:
#!/usr/bin/env ruby
require 'rubygems'
require 'ftpfxp' #required for FTP/TLS
require 'ptools' #required to tell if a file is text or binary
puts 'Connecting...'
HOST='192.168.2.12'
USER='ftptest2'
#!/bin/csh
#06/24/2013
#Lampros for WeirdBricks
#check if curl exists
if ( -e `which curl` ) then
echo "OK: Curl exists"
else
echo "ERROR:curl doesn't exist"
@weirdbricks
weirdbricks / git101
Last active August 29, 2015 13:56
starting-with-a-new-repository
1. Create new repository, go here:
https://github.com/new
2. Give it a name and tick 'Initialize this repository with a README', then click on 'Create Repository', for this example the name will be 'reload-jail'
3. On your shell initialize the new repository:
git init reload-jail
4. Go into the repository directory:
cd reload-jail/
@weirdbricks
weirdbricks / ansible-01
Created February 15, 2014 03:36
ansible notes on converting the packaging system and installing apache in ad-hoc mode
ansible jail1 -m raw -a "pkg_add -r pkg python27"
ansible jail1 -m file -a "dest=/usr/local/etc/pkg/repos/ owner=root group=wheel state=directory"
ansible jail1 -m copy -a "src=/root/FreeBSD.conf dest=/usr/local/etc/pkg/repos/FreeBSD.conf"
ansible jail1 -m raw -a "pkg2ng"
ansible jail1 -m raw -a "pkg update -f"
ansible jail1 -m raw -a "pkg upgrade -y"
ansible jail1 -m raw -a "pkg update -f"
ansible jail1 -m pkgng -a "name=apache22 state=present cached=no"
#!/usr/bin/env sh
#checks if the speaker module is loaded - if not it loads it and makes a be
#based on http://forums.freebsd.org/viewtopic.php?t=12001
module=`kldstat | grep speaker -c`
if [ $module -eq 0 ]
then
echo "speaker module not found - adding"
@weirdbricks
weirdbricks / mfs-chunkserver.yaml
Last active August 29, 2015 14:02
MooseFS Chunk Server Ansible recipe for FreeBSD
---
- hosts: all
remote_user: root
tasks:
- name: test
raw: uptime
- name: ping them
ping:
- name: install moosefs chunkserver from packages
pkgng: name=moosefs-chunkserver state=present
@weirdbricks
weirdbricks / memory-cloudwatch.yaml
Created June 15, 2014 22:22
ansible playbook to add memory metrics for cloudwatch - RedHat family only
- hosts: all
vars:
ec2_access_key: "AKIA-----------A"
ec2_secret_key: "i-------------/--------A"
remote_user: ec2-user
sudo: yes
tasks:
- name: "make sure package perl-switch is installed for the monitoring scripts"
yum: name=perl-Switch state=present
when: ansible_os_family == "RedHat"
@weirdbricks
weirdbricks / wc.rb
Created September 16, 2014 22:57
wc replacement in ruby
#!/usr/bin/ruby
#By Lampros Chaidas
#wc replacement in ruby
input = $stdin.read
words = input.split(" ").count
newlines = input.lines.count
characters = input.length
@weirdbricks
weirdbricks / cat.rb
Created September 16, 2014 23:00
cat replacement in ruby
#!/usr/bin/ruby
#by Lampros Chaidas
#cat replacement in ruby - if the -n switch is provided the lines start with a number
#check if the -n option is given to prepend each line with a line number
if ARGV.include? "-n"
@lines=true
ARGV.delete("-n")
end