Skip to content

Instantly share code, notes, and snippets.

View invalidusrname's full-sized avatar
🤷‍♀️

Matt invalidusrname

🤷‍♀️
View GitHub Profile
@invalidusrname
invalidusrname / convert_to_duration.rb
Last active April 3, 2019 20:39
Makes a select tag (1-30min with 30 sec intervals)
def convert_to_duration(fixnum)
min = (fixnum / 60).to_s.rjust(2, '0')
sec = (fixnum % 60).to_s.rjust(2, '0')
"00:#{min}:#{sec}"
end
(1.minute..30.minutes).step(30).collect { |s| convert_to_duration(s) }
# 00:01:00
# 00:01:30
@invalidusrname
invalidusrname / hpricot.rb
Last active April 3, 2019 20:37
converting html codes
# supposed to be Dash —
Hpricot("<p>Dash —</p>").to_plain_text
# => "Dash ?"
# would like text to convert to
#'Dash -'
@invalidusrname
invalidusrname / constant_check.rb
Created January 7, 2009 03:49
constants being loaded twice? Use this
RAILS_DEFAULT_LOGGER.debug(caller.join("\n")) if defined? SOME CONSTANT
@invalidusrname
invalidusrname / rails_2_3_failing_tests.log
Last active April 3, 2019 20:02
Rails 2.3 RC failing tests
$ ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin9]
$ rails -v
Rails 2.3.0
$ rails testo
$ cd testo
$ ./script/generate model user name:string
$ rake db:migrate
$ rake test
@invalidusrname
invalidusrname / mysql_gemfix.sh
Last active April 3, 2019 20:03
mysql 5 with Rails
# needed to install mysql gem (wasn't bundled in rails 2.2 anymore)
sudo gem install mysql -- --with-mysql-include=/opt/local/include/mysql5/mysql/ --with-mysql-lib=/opt/local/lib/mysql5/mysql/ --with-mysql-config=/opt/local/bin/mysql_config5
@invalidusrname
invalidusrname / redmine post-receive hook
Created April 3, 2009 16:03
redmine post-receive hook
#!/bin/bash
#
# An example hook script for the post-receive event
#
# This script is run after receive-pack has accepted a pack and the
# repository has been updated. It is passed arguments in through stdin
# in the form
# <oldrev> <newrev> <refname>
# For example:
# aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master
@invalidusrname
invalidusrname / markup_list.php
Last active April 3, 2019 20:53
can't remember this one
<?php
function markup_list($data, $path, $use_links = true) { // can handle 1 or 2d array
// array_flip($columns);
$output .= "<div class=\"classlist\">\n";
foreach ($data as $var => $val) {
$target_kv = explode("=", $var); // break up compound string into key/value
if ($use_links) {
$output .= '<p><a href="'.$path.'?'.$target_kv[0].'='.$target_kv[1].'">'.$target_kv[1]."</a></p>\n";
}
@invalidusrname
invalidusrname / pre-commit
Last active April 3, 2019 20:04
git pre-commit hook to cleanup whitespace #git
#!/bin/sh
# Clean up whitespace in any modified files.
if git-rev-parse --verify HEAD > /dev/null
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
@invalidusrname
invalidusrname / commands.sh
Last active April 3, 2019 20:04
update passenger on ubuntu
gem install passenger
passenger-install-apache2-module
sed -i 's/passenger-2\.2\.4/passenger-2\.2\.7/g' /etc/apache2/conf.d/passenger.conf
apache2ctl restart
tail /var/log/apache2/error.log
@invalidusrname
invalidusrname / git_update_index.sh
Last active April 3, 2019 20:05
ignore a file that's already ignored with gitignore
git update-index --assume-unchanged <filename>