Skip to content

Instantly share code, notes, and snippets.

@counterbeing
counterbeing / smiley
Created June 23, 2011 03:09
Other uses for gist.
###### ######
########## ##########
############ ############
############## ##############
############## ##############
############## ##############
############ ############
########## ##########
###### ######
$(function () { // I assume i need to name this funciton and call it more than once
var availableTags = $("#client_spec_list").attr("data-autocomplete");
// The line above I need to remove the ID, and make it a variable.
availableTags = availableTags.split(",")
function split( val ) {
return val.split( /,\s*/ );
}
function extractLast( term ) {
return split( term ).pop();
}
function war(enemy,reason) {
if(!enemy) { //The mandatory argument is not present - die with error(no pun intended)
alert("Please choose an enemy before starting a war");
return false;
}
if(!reason) { //If the optional argument is not there, create a new variable with that name.
var reason = "They have Nukes!";
}
@counterbeing
counterbeing / gist:1387277
Created November 22, 2011 22:40
Puppet, case within case?
# Is this legal? Not sure if it's working
class ard_for_mcs_only {
case $kernel {
"Darwin": {
case $ard_running {
false: {
# Use the kickstart app to declare that only MCS can use ARD and it had better be running
exec {"/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -privs -all -users mcs":}
# Hey all! I've to something that I've been trying to understand for the past couple of hours. I'm trying to accept
# some information via Post from an external application, I'm having trouble because I have no control over how the
# external application forms its post. So here are the parameters I get from it, and the parameters, i WANT to get
# from it. I'm wondering if there's some way to transform its parameters so that they fit into my model... Thanks!
## What I get:
Started POST "/prey_reports" for 10.0.111.12 at 2012-02-20 16:00:22 -0800
Processing by PreyReportsController#create as */*
Parameters: {"network"=>{"public_ip"=>"24.5.106.189", "internal_ip"=>"10.0.121.12", "gateway_ip"=>"10.0.121.1", "mac_address"=>"00:26:5b:14:f5:58", "active_connections"=>"Active%20Internet%20connections%20%28including%20servers%29%0AProto%20Recv-Q%20Send-Q%20%20Loca
Processing NodesController#update (for 10.100.107.1 at 2012-03-03 17:53:02) [PUT] 
Parameters: {
"node"=>{
"assigned_node_group_ids"=>["2,"],
"parameter_attributes"=>[{"value"=>"", "key"=>""}],
"description"=>"",
"assigned_node_class_ids"=>[""]},
"action"=>"update",
"_method"=>"put",
"authenticity_token"=>"Jtd49SzNwfipSU877ZMfpoWo11AGvC7wMnJ33S7sXXs=",
@counterbeing
counterbeing / gist:2304772
Created April 4, 2012 19:01
IT Cheat code
cat /etc/pam.d/screensaver | sed 's/account required pam_group.so no_warn group/account sufficient pam_group.so no_warn group'/ > /Users/Shared/screensaver.new.txt
sudo mv /etc/pam.d/screensaver /Users/Shared/screensaver.old.txt
sudo cp /Users/Shared/screensaver.new.txt /etc/pam.d/screensaver
@counterbeing
counterbeing / gist:3764964
Created September 22, 2012 02:56
Playing with shuffle
def shuffle arr
shuf = []
while arr.length > 0 # Randomly pick one element of the array.
rand_index = rand(arr.length)
curr_index = 0
new_arr = []
arr.each do |item|
if curr_index == rand_index
shuf.push item
else
test "product price must be positive" do
product = Product.new(title: "My Book Title",
description: "yyy",
image_url: "zzz.jpg")
product.price = -1
assert product.invalid?
assert_equal "must be greater than or equal to 0.01",
product.errors[:price].join('; ')
product.price = 0
@counterbeing
counterbeing / gist:5707316
Last active December 18, 2015 01:59
Traceroute for Mediatemple
traceroute mediatemple.net
traceroute to mediatemple.net (64.2X7.129.XXX), 64 hops max, 52 byte packets
1 172.20.10.1 (172.20.10.1) 0.807 ms 0.628 ms 0.607 ms
2 10.98.27.241 (10.98.27.241) 98.463 ms 61.542 ms 57.024 ms
3 10.98.27.173 (10.98.27.173) 70.110 ms 59.296 ms 59.884 ms
4 10.98.20.170 (10.98.20.170) 99.837 ms 59.500 ms 60.608 ms
5 10.98.20.177 (10.98.20.177) 52.740 ms 53.021 ms 56.928 ms
6 10.98.20.161 (10.98.20.161) 60.030 ms 50.612 ms 68.782 ms
7 * * *
8 10.192.37.213 (10.192.37.213) 118.458 ms 59.497 ms 50.218 ms