Skip to content

Instantly share code, notes, and snippets.

Joshua Wilcox joshuaswilcox

Block or report user

Report or block joshuaswilcox

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View serversetup.md

Ubuntu 14.04, RoR, Nginx, Puma, Postgresql and Capistrano deploy#

Server Setup

  • Create new server
  • Login to new server
    • ssh root@IPaddress
    • accept the RSA key
    • use the password that was provided when you set up the new server:
      • change the password:
View .bash_profile
# Colours
txtgrn='\[\e[0;32m\]' # Green
txtylw='\[\e[0;33m\]' # Yellow
txtblu='\[\e[0;34m\]' # Blue
txtpur='\[\e[0;35m\]' # Purple
txtcyn='\[\e[0;36m\]' # Cyan
txtwht='\[\e[0;37m\]' # White
bldblk='\[\e[1;30m\]' # Black - Bold
bldred='\[\e[1;31m\]' # Red - Bold
bldgrn='\[\e[1;32m\]' # Green - Bold
View capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@joshuaswilcox
joshuaswilcox / current_song
Last active Sep 27, 2019
Applescript to show current playing song and determine if its spottily or iTunes that is playing
View current_song
if application "Spotify" is running and application "iTunes" is not running then
tell application "Spotify"
if player state is stopped then
set display to "No Track Playing"
else
set track_artist to artist of current track
set track_name to name of current track
set track_duration to duration of current track
set seconds_played to player position
set state to ""
View gist:7224074
ac99f3707a11b13f224eba8494a6e52d1147b305
b5cf5f67e39f96d264183d3fa960ba0a4a305486
029cb9028a2e310beff924ae191656156b9c289b
88cbecb8c44ec0ed66f8a677727a61778937b1a9
7c39757cdbf4ac915d598e76baa6d1c8e1a5c943
7e863a767765eebd370a5b61ea624f12fafbb281
5a8a6000bc23806d7150c91173b9093f09e8054b
00436635cae517a3ec2a224896f2a9ed4f2e6525
1871f3fd7cc2e1396e1a4cf90a8cc94a97645f15
f60ffe95124e03f339c241598212a7c3204f0171
@joshuaswilcox
joshuaswilcox / geek_ch
Last active Dec 26, 2015
Get latest Calvin and Hobbes comic and save to folder
View geek_ch
#!/usr/bin/env ruby
require 'nokogiri'
require 'net/http'
require 'open-uri'
require 'cgi'
require "fileutils"
# folder where to save the comic to
$basedir = '~/Documents/geeklets/ch_comic'
View gist:7156504
GIT
remote: https://github.com/jackdempsey/acts_as_commentable.git
revision: e9baa4826f92c80f90b6e589fd73aa5a0a54851b
specs:
acts_as_commentable (4.0.0)
GIT
remote: https://github.com/mbleigh/acts-as-taggable-on.git
revision: 98aecdd86ddf447a88ae6351cc02ab420a78d0ec
specs:
View gist:7106954
Top 10 slowest examples (450.02 seconds, 65.1% of total time):
User searches user search features and there are no results
74.77 seconds ./spec/features/search_spec.rb:11
User searches user search features and they sort by title
62.61 seconds ./spec/features/search_spec.rb:32
User searches user search features and they filter with a facet
54.08 seconds ./spec/features/search_spec.rb:26
User searches user search features and they sort by date
46.35 seconds ./spec/features/search_spec.rb:39
User searches user search features and there are less than 10 results
View gist:7086528
//This is the video player object
//<video id="video-mp4" class="video-js vjs-default-skin"
// controls preload="auto" width="100%" height="350"
// data-setup='{}'
// poster="http://video-js.zencoder.com/oceans-clip.png">
// <source src="http://localhost:3000/assets/barcode64408.mp4" type='video/mp4' />
// </video>
$(function() {
var player = videojs('video-mp4');
@joshuaswilcox
joshuaswilcox / Ruby String Trim at Full Word
Created Nov 8, 2012
Trims ruby string to set length maintaining full words
View Ruby String Trim at Full Word
def desc_trim
@string = self.description.to_s
@max = 120
if @string
if @string.size > @max
@words = @string.split(' ')
@end = "..."
@output = ''
i = 0
@words.each_with_index do |w, i|
You can’t perform that action at this time.