Skip to content

Instantly share code, notes, and snippets.

View jamesmichiemo's full-sized avatar
☯️
casting lots

Mana jamesmichiemo

☯️
casting lots
  • University of North Carolina
View GitHub Profile
@jamesmichiemo
jamesmichiemo / serverPID.sh
Created March 5, 2014 03:52
a script that identifies the PID of a running server.
lsof -wni tcp:3000
@jamesmichiemo
jamesmichiemo / setRemote.sh
Created March 5, 2014 06:57
After changing the name of a remote repository, I found that I was unable to push any commits in my branch. I had to reset the remote url locally by using these git commands.
#check the current url to see if it matches the remote url
git remote -v
#update to new url with command
git remote set-url origin git@github.com:username/newreponame.git
#ls remote branches to confirm connection
git ls-remote
@jamesmichiemo
jamesmichiemo / remove.sh
Created April 17, 2014 13:58
file removal from git history
git filter-branch --index-filter 'git rm --cached --ignore-unmatch screenshot.png' -- --all
sum = 0
(0...1000).each do |i|
sum += i if (i%3 == 0 || i%5 == 0)
end
puts "The sum total of all the multiples of 3 or 5 is #{sum}."
puts 'Enter maximum range of Fibonacci sequence:'
num = gets.chomp.to_i
def fib(num)
sum = 0·
first = 0
second = 1
even = 0
(1..num).each do |i|
require 'prime'
p 'enter number:'
num = gets.chomp.to_i
def prime(num)
pfactor = num.prime_division
puts "The largest prime factor of #{num} is #{pfactor.last[0]}."
end
@jamesmichiemo
jamesmichiemo / app.rb
Created May 28, 2014 05:00
Sinatra API for Blogging using AJAX
# libraries that must be installed before use
require 'rubygems'
require 'sinatra'
require 'mongo'
require 'json/ext'
require 'date'
# create mongo instance
include Mongo
@jamesmichiemo
jamesmichiemo / ajax_json.coffee
Created June 22, 2014 11:51
an example for gathering JSON data for Handlebars templating
source = $("#id_on_handlebars_script_tag").html()
template = Handlebars.compile source
$.getJSON('some route to json markup', (data)->
$("#content_placeholder").html(template data)
).error ->
console.log "error"
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<polymer-element name="my-element">
@jamesmichiemo
jamesmichiemo / leading_zeros.rb
Last active August 29, 2015 14:11
Leading zeros
'%03d' % 1 # 001