Skip to content

Instantly share code, notes, and snippets.

@chrisbodhi
chrisbodhi / CLI Alias
Last active August 22, 2019 12:53
Alias for my command line
# Located in ~/.zshrc
ZSH_THEME="muse"
alias desk="cd ~/Desktop"
alias code="cd ~/Code"
alias git="hub"
alias ga="git add"
alias gc="git commit"
alias gpom="git push origin master"
require 'open-uri'
require 'nokogiri'
require 'mechanize'
def ffffound_pages(number)
pg_counter = 0
while pg_counter < 25*number
@chrisbodhi
chrisbodhi / char_count.rb
Created February 21, 2014 15:59
Take input from a text file & output the response to a new text file
# Open the source file & store each element in an array
# (sans the newline character)
def parse_file(file)
arr = []
list = File.open(file)
list.each do |item|
if item.include? "\n"
arr << item.chomp
else
arr << item
@chrisbodhi
chrisbodhi / form-controller.js
Last active August 29, 2015 14:10
Angular.js form controller used with the KickoffLabs API
app.controller('FormController', function( $scope, $http, $routeParams ){
'use strict';
var self = this,
kickoffId = '99999', // https://app.kickofflabs.com/dashboard/campaigns/36854/api
url,
config,
socialRef,
id;
if file_info[:control_info].length > 0
all_keys = []
keys = []
file_info.each do |fi|
fi[:control_info].each do |arr|
keys << arr[1]
end
all_keys += [keys]
keys = []
end
@chrisbodhi
chrisbodhi / index.html
Last active August 29, 2015 14:14
test index
<!DOCTYPE html>
<html>
<head>
<script src="https://www.dropbox.com/s/l6hgjq7mh52o6od/spiceworks-sdk.js?dl=1&raw=1" type="text/javascript"></script>
<script src="https://code.jquery.com/jquery-2.1.3.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
var card = new SW.Card();
var inventory = card.services('inventory');
inventory.request('devices').then(function(data){
@chrisbodhi
chrisbodhi / update_xml_file.rb
Last active August 29, 2015 14:15
Add to an XML File
def update_xml_file(string_to_add, file)
# Ready a formatted string and XML'ify it
new_xml = Nokogiri::XML::DocumentFragment.parse(string_to_add)
# Open the XML file to which we add
@xml_file = Nokogiri::XML(File.read(file))
# Find the last instance of the `here` node
@insertion_point = @xml_file.css('here').last
# Stick the XML'ified string after the last 'here' node
@insertion_point.add_next_sibling(new_xml)
# Save it all
@chrisbodhi
chrisbodhi / get_ip_factory
Created February 12, 2015 17:35
An Angular factory to retrieve the user's IP address
app.factory( 'getIP', function ( $http ) {
'use strict';
var self = this;
return function getIP () {
self.ipCheck = 'http://ipinfo.io/json';
return $http.get(self.ipCheck)
.then(function (result){
return result;
<!DOCTYPE html>
<html>
<head>
<script src="https://www.dropbox.com/s/l6hgjq7mh52o6od/spiceworks-sdk.js?dl=1&raw=1" type="text/javascript"></script>
<script src="https://code.jquery.com/jquery-2.1.3.min.js" type="text/javascript"></script>
<script src="http://d3js.org/d3.v3.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
var card = new SW.Card();
var tix = card.services('helpdesk');
require 'minitest/autorun'
class RobotTest < MiniTest::Unit::TestCase
def test_name_sticks
robot = Robot.new
robot.name
assert_equal robot.name, robot.name
end
end