Skip to content

Instantly share code, notes, and snippets.

View dinjas's full-sized avatar
:shipit:
Alive

Jason Dinsmore dinjas

:shipit:
Alive
  • Battle Ground, WA
View GitHub Profile
class CoursesController < ApplicationController
require "rexml/document"
require "net/http"
require "multipart"
include REXML
before_filter :check_login, :only => ['new', 'create', 'admin_pub']
before_filter :login_required, :except => ['index', 'list', 'search', 'show']
before_filter :check_permissions, :only => ['edit', 'update']
#!/bin/sh
RSYNC_DEFAULT_OPTIONS="-r -t -v -L --delete --stats --progress"
RSYNC_TEMP_DIR="./tmp_rsync_dir/"
# Sources
ITUNES_PODCASTS_DIR="/Users/adam/Music/iTunes/iTunes Music/Podcasts/"
ITUNES_MUSIC_DIR="/Users/adam/Music/iTunes/iTunes Music/"
ALBUMS=(
"Bone Thugs-N-Harmony/Strength & Loyalty"
@dinjas
dinjas / dinjahelper.html
Created October 6, 2011 18:41
Simple html file that allows you to enter # of minutes to convert to hundredths of an hour (e.g. 15 minutes = 25 hundredths of an hour)
<html>
<head>
<style type="text/css">
h2 {
text-align: center;
}
div#minute-converter {
background: #cfcfcf;
width: 500px;
height: 725px;
@dinjas
dinjas / Fancy File Inputs.js
Created January 13, 2012 06:24 — forked from davist11/Fancy File Inputs.js
Fancy File Inputs
var SITE = SITE || {};
SITE.fileInputs = function() {
var $this = $(this),
$val = $this.val(),
valArray = $val.split('\\'),
newVal = valArray[valArray.length-1],
$button = $this.siblings('.button'),
$fakeFile = $this.siblings('.file-holder');
if(newVal !== '') {
@dinjas
dinjas / en.yml
Created January 27, 2012 02:18 — forked from chrisbloom7/01-validates-file-size-carrierwave.md
A cheap knock off of the default validates_length_of validator, but checks the filesize of a Carrierwave attachment
# config/locales/en.yml
en:
errors:
messages:
wrong_size: "is the wrong size (should be %{file_size})"
size_too_small: "is too small (should be at least %{file_size})"
size_too_big: "is too big (should be at most %{file_size})"
@dinjas
dinjas / avatar_uploader.rb
Created February 2, 2012 21:56 — forked from kirs/avatar_uploader.rb
Validation of image dimensions with CarrierWave
# encoding: utf-8
class AvatarUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
storage :file
# Override the directory where uploaded files will be stored.
@dinjas
dinjas / hack.sh
Created March 31, 2012 22:43 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
- (IBAction)startThePlan:(id)sender {
ScheduleViewController *scheduleVC = [[ScheduleViewController alloc] initWithNibName:nil bundle:nil];
[self.navigationController pushViewController:scheduleVC animated:YES];
NSMutableArray *allViewControllers = [NSMutableArray arrayWithArray:self.navigationController.viewControllers];
int length = [allViewControllers count];
[allViewControllers objectAtIndex:length-1]; // remove confirmation view
[allViewControllers objectAtIndex:length-2]; // remove start date view
[allViewControllers objectAtIndex:length-3]; // remove plan selection view
@dinjas
dinjas / url_shortener.js
Last active November 24, 2018 09:17
Simple shortener of an integer string into a base62 string. Sample usage at bottom of each file.
var codeset = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var base = codeset.length;
function encode(intStr) {
var hash = "";
intStr = parseInt(intStr);
while (intStr > 0) {
hash = self.codeset[parseInt(intStr % base)] + hash;
intStr = Math.floor(intStr / base);
}
#!/usr/bin/env ruby
PRESUMPTIVE_RAILS_ROOT = "/data/[APP_NAME]/current"
LOG_PATH = "/data/[APP_NAME]/shared/log/delayed_job_singleton.log"
Dir.chdir PRESUMPTIVE_RAILS_ROOT
require 'home_run'
require "rubygems"
require "bundler/setup"