Skip to content

Instantly share code, notes, and snippets.

@zyphlar
zyphlar / git-collab.md
Last active December 23, 2015 02:29
How to use Git collaboratively (assuming you're already comfortable working alone with git status / git log / git add / git commit / git push)

For the basics, check out this resource: http://rogerdudler.github.io/git-guide/

Create a separate branch for each story being worked on. New branches should be rooted in the master branch. Here's a sample process to follow:

Creating a branch

  1. git checkout master
  2. git pull
  3. ... fix any merge conflicts ...
  4. git checkout -b new-story
@zyphlar
zyphlar / jiggler.sh
Last active December 23, 2015 03:28
Jiggle your scripts!
#!/bin/bash
echo "Script jiggler initiated."
echo 'touch my-script.sh'
touch my-script.sh
echo 'ls -al | grep my-script.sh'
ls -al | grep my-script.sh
DATEDOWN=$(date --date="25 hours ago")
DATEUP=$(date)
@zyphlar
zyphlar / macs.rb
Created September 27, 2013 06:11
Trying to get a total amount of time spent "active" for each MAC, excluding unmatched entries.
1.9.3-p385 :117 > recent_mac_logs = MacLog.last(8).group_by(&:mac)
MacLog Load (0.7ms) SELECT "mac_logs".* FROM "mac_logs" ORDER BY id DESC LIMIT 10
=>{
"00:01:02:03:04:04"=>
[#<MacLog id: 30003, mac: "00:01:02:03:04:04", ip: "1.2.3.3", action: "activate", created_at: "2013-09-27 04:35:04">],
"00:01:02:03:04:05"=>
[#<MacLog id: 30036, mac: "00:01:02:03:04:05", ip: "1.2.3.4", action: "deactivate", created_at: "2013-09-27 05:15:04">],
"00:01:02:03:04:06"=>
[
#<MacLog id: 30038, mac: "00:01:02:03:04:06", ip: "1.2.3.5", action: "deactivate", created_at: "2013-09-27 05:25:04">,
@zyphlar
zyphlar / tweet.py
Created October 17, 2013 05:40
Tweet from Python
# /usr/bin/env python
#We need the tweepy library
import tweepy
import sys
#Keyz
consumer_key=""
consumer_secret=""
@zyphlar
zyphlar / xerocraftSkullMouth.ino
Last active December 27, 2015 07:09
Routine to control a linear actuator using the Servo library to open and close a robotic mouth.
// Xerocraft Skull Mouth Servo Control
// by Will Bradley @willbradley
// This code is in the public domain.
// Usage:
// connect servoPin to the servo RX
// connect GND to the servo's GND
// tweak min/max as desired
@zyphlar
zyphlar / output.json
Last active December 28, 2015 17:39
Output from Nutritionix search for "beet"
{[
{"_index"=>"nixproductionv12", "_type"=>"item", "_id"=>"5283952d7879a20200001a77", "_score"=>1.1065075, "fields"=>
{"old_api_id"=>nil, "item_id"=>"5283952d7879a20200001a77", "item_name"=>"Red Beet & Cabbage Sauerkraut Salad", "brand_id"=>"51db37b8176fe9790a898ac3", "brand_name"=>"Wildbrine", "item_description"=>nil, "updated_at"=>"2013-11-13T15:05:17.862Z", "nf_ingredient_statement"=>nil, "nf_water_grams"=>nil, "nf_calories"=>10, "nf_calories_from_fat"=>0, "nf_total_fat"=>0, "nf_saturated_fat"=>nil, "nf_trans_fatty_acid"=>nil, "nf_polyunsaturated_fat"=>nil, "nf_monounsaturated_fat"=>nil, "nf_cholesterol"=>nil, "nf_sodium"=>280, "nf_total_carbohydrate"=>2, "nf_dietary_fiber"=>0.5, "nf_sugars"=>1, "nf_protein"=>0, "nf_vitamin_a_dv"=>6, "nf_vitamin_c_dv"=>20, "nf_calcium_dv"=>nil, "nf_iron_dv"=>nil, "nf_refuse_pct"=>nil, "nf_servings_per_container"=>17, "nf_serving_size_qty"=>2, "nf_serving_size_unit"=>"tbsp", "nf_serving_weight_grams"=>30}},
{"_index"=>"nixproductionv12", "_type"=>"item", "_id"=>"513fceb5
<!-- On this page: http://action.phoenixchildrens.com/site/TR?pg=fund&fr_id=1060&pxfid=3081
This code: -->
<div class="ui-dialog ui-widget ui-widget-content ui-corner-all full-donor-list ui-draggable" tabindex="-1" role="dialog" aria-labelledby="ui-dialog-title-fullWall" style="display: block; z-index: 1002; outline: 0px; height: auto; width: 400px; top: 0px; left: 0px;">
<!-- Should be this instead: -->
<div class="ui-dialog ui-widget ui-widget-content ui-corner-all full-donor-list ui-draggable" tabindex="-1" role="dialog" aria-labelledby="ui-dialog-title-fullWall" style="display: block; z-index: 1002; outline: 0px; height: auto; width: 400px; top: 300px; left: 35%;">
class Project
has_many :project_items
has_many :features, through: :project_item
has_many :milestones, through: :project_item
# stuff
end
class ProjectItem
@zyphlar
zyphlar / nmap.sh
Last active December 30, 2015 18:19
Monitoring Network Performance with NMap and pfSense
nmap -v -sn 192.168.1.0/24 -oX /tmp/nmap-ping.log --append-output
@zyphlar
zyphlar / pfsense-pinger-cron.txt
Last active December 30, 2015 18:19
Pinging a subnet, logging it to a file, and viewing that file in pfSense.
# Either put the line below at /etc/crontab or in the Cron service package in the webui.
* * * * * root /usr/bin/nice -n20 /root/pinger.sh 192.168.1. >> /tmp/ping.log