Skip to content

Instantly share code, notes, and snippets.

View hanynowsky's full-sized avatar
💭
I may be slow to respond.

Hanynowsky hanynowsky

💭
I may be slow to respond.
View GitHub Profile
@hanynowsky
hanynowsky / gist:4302692
Created December 16, 2012 02:52
Jambi-Sample
package jambi;
import com.trolltech.qt.gui.*;
public class HellowWorld {
public static void main(String args[]) {
QApplication.initialize(args);
QPushButton hello = new QPushButton("Hello World!");
hello.resize(120, 40);
#!/bin/sh
sudo yum -y install js-devel
mkdir -p ~/bin
curl -L http://github.com/micha/jsawk/raw/master/jsawk > ~/bin/jsawk
chmod 755 ~/bin/jsawk
<% header "Content-Type" => "text/html" %>
<h1>Let's run some ruby code: <%= rand %></h1>
#!/usr/bin/env ruby
# estimate the dewpoint temperature
def dew_point(temp, rv)
e = 6.1121 * (10 ** (7.502 * temp / (237.7 + temp)))
p = (rv * e) / 100.0
dp = (-430.22 + 237.7 * Math.log(p))/(-(Math.log(p)) + 19.08);
end
# estimate the wet bulb temperature

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

yum -y install autoconf automake bison byacc cpp curl flex gcc gdb git glibc-devel libgcrypt-devel libtool libtool-ltdl-devel m4 make nc pkgconfig rpm-build screen strace tar valgrind vim which OpenIPMI-devel curl-devel ganglia-devel gtk2-devel iptables-devel java-1.7.0-openjdk-devel java-devel jpackage-utils libdbi-devel libesmtp-devel libmemcached-devel libmnl-devel libnotify-devel liboping-devel libpcap-devel librabbitmq-devel libvirt-devel libxml2-devel lm_sensors-devel lvm2-devel mysql-devel net-snmp-devel nut-devel openldap-devel perl-ExtUtils-Embed postgresql-devel protobuf-c-devel python26-devel rrdtool-devel varnish-libs-devel openldap-devel
# Linux. Act upon an event in a log file
# www.fduran.com
apt-get upgrade; apt-get install inotify-tools
# create file myalert.sh:
# example finding Exception in tomcat log and sending email
#!/bin/bash
while inotifywait -e modify /path/to/file.log; do
vagrant@precise64:~$ irb
1.9.3-p484 :002 > require "riemann"
=> true
# Activate maintenance-mode:
1.9.3-p484 :010 > Riemann::Client.new << {service: "maintenance-mode", host: "precise64", state: "active", ttl: Float::INFINITY}
=> nil
# Deactivate maintenance-mode:
1.9.3-p484 :011 > Riemann::Client.new << {service: "maintenance-mode", host: "precise64", state: nil, ttl: Float::INFINITY}
=> nil
@hanynowsky
hanynowsky / README.md
Last active August 29, 2015 14:17 — forked from jrydberg/README.md

Riemann is a quite simple but powerful monitoring system. In its core it is an event processing framework allowing a user to handle an incoming event stream. Events are small objects that originate from a host, that has a service and metric value associated with it. Events may also have tags and a free text description. This simple data structure enables an application transmit both exception tracebacks and application metric data using the same mechanism.

Riemann has a few problems though. First, it is a single-machine application, only allowing vertical scaling. Secondly, there's no redundancy or availability solution. In this post we'll try to address the first issue.

@hanynowsky
hanynowsky / koji-package-remover
Created April 28, 2015 08:53
force removal of a Koji package
WORKDIR="/tmp"
SQLFILE=$1.sql
cat > $WORKDIR/$SQLFILE << EOF
delete from tag_listing where build_id in (select id from build where pkg_id in (select id from package where name = '$1'));
delete from rpmsigs where rpm_id in (select id from rpminfo where build_id in (select id from build where pkg_id in (select id from package where name = '$1')));
delete from buildroot_listing where rpm_id in (select id from rpminfo where build_id in (select id from build where pkg_id in (select id from package where name = '$1')));
delete from rpminfo where build_id in (select id from build where pkg_id in (select id from package where name = '$1'));
delete from build where pkg_id = (select id from package where name = '$1');
delete from tag_packages where package_id = (select id from package where name = '$1');
delete from package where name = '$1';