Skip to content

Instantly share code, notes, and snippets.

View joshrendek's full-sized avatar

Josh Rendek joshrendek

View GitHub Profile
#!/usr/bin/python
import urllib2, urllib, socket
username = 'USERNAME'
password = 'PASSWORD'
ip = socket.gethostbyname(socket.gethostname())
gateway = ip.split('.')
gateway[3]='1'
gatewayip = gateway[0:4]
gate_ip = ".".join(gatewayip)
gatesip = "http://",gate_ip,"/login.pl"
#!/bin/env php
<?php
$host = "http://servly.com/rrd/update";
error_reporting(E_NONE);
echo "\n";
$mon = array();
sleep(5); // so it reads properly
/* CPU Usage */
$cpu = `sar 1 | awk 'END {print \$NF}'`;
$mon[cpu][free] = $cpu;
Make this a file, executable, add this to cron:
*/5 * * * * root /path/to/script;
Requirements: sysstat package on CentOS (yum install sysstat) || or just the sar command
#!/bin/env php
<?php
$host = "http://servly.com/rrd/update";
error_reporting(E_NONE);
echo "\n";
class SignupController < ApplicationController
layout "signup"
def index
require "digest"
if request.post?
@user = User.create(:email => params[:signup][:email], :username => params[:signup][:username], :password => Digest::SHA1.hexdigest(params[:signup][:password]))
end
end
end
/*
Copyright Josh Rendek 2009
http://bluescripts.net/
Not liable for anything
1m6sec to process a 1.8GB File
*/
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
class Canonical
def initialize(eq)
@eq = eq.split('+')
@new_eq = []
end
def binary_to_decimal(x)
y = 1
z = 0
#!/usr/bin/ruby
#script that will download images off of 4 chan
require 'rubygems'
require 'active_record'
require 'hpricot'
require 'rest-open-uri'
require 'net/http'
def self.get_search_results(query)
# API request variables
endpoint = 'http://svcs.ebay.com/services/search/FindingService/v1'; # URL to call
version = '1.0.0'; # API version supported by your application
appid = 'YOUR APP ID'; # Replace with your own AppID
globalid = 'EBAY-US'; # Global ID of the eBay site you want to search (e.g., EBAY-DE)
safequery = URI.encode(query); # Make the query URL-friendly
# Construct the findItemsByKeywords HTTP GET call
apicall = "#{endpoint}?";
def self.search(term, per_page, page, subdomain_id)
conditions, conditional = Array.new, Array.new
# made prettier by an array and a join
self.column_names.collect { |c| c != "subdomain" ? conditional << "#{c} LIKE '%%%s%%'" : "" }
# wrap around SQL logic for making sure search only returns results pertinent to domain
conditions.push("(" + conditional.join(' OR ') + ") AND subdomain = '#{subdomain_id}'")
# push the search term into the conditions -- replacing the %%s%%
def get_object
type = params['event_id'] ? 'event' : 'person'
value = type.classify.constantize.find(params[:"#{type}_id"])
name = '@' + type
instance_variable_set(name , value)
end