Skip to content

Instantly share code, notes, and snippets.

View m3talsmith's full-sized avatar

Michael Christenson II m3talsmith

View GitHub Profile
<html>
<head>
<title>Side Scroller</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<style type="text/css">
#posts {position: relative; width: 300px;}
.controls {position: relative; height: 2em; width: 100%;}
.controls .control {position: absolute; top: 0px; cursor: pointer;}
#post_controls #left {left: 0px;}
#post_controls #right {right: 0px;}
/* Array Monkey Patching */
Array.prototype.includes = function(value) {
var length = this.length;
for(var i=0; i < length; i++) {
if(this[i] == value) { return true; }
}
return false;
}
javascript:Ai7Mg6P='';
var images=document.getElementsByTagName('img');
if(images.length>=1){
var images_string='';
for(i7M1bQz=0;i7M1bQz<images.length;i7M1bQz++){
var image_src=images[i7M1bQz].src;
images_string+=('<img style=\'pointer:cursor;\' src=\''+image_src+'\' onClick="location.href=\'http://user.adme.in/blog/add?username=username&access=access_id&img='+image_src+'&title='+encodeURIComponent(document.title)+'&url='+encodeURIComponent(location.href)+'\'" />');
}
document.write('<center><h2>Click on an image to post it on your wall</h2><br /><div id=\'photoblog-images\'>'+images_string+'</div></center>');
}else{alert('There are no images on this page. Please find the image you would like and try again.');}
# -- git parsed prompt --
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
PS1="${debian_chroot:+($debian_chroot)}\[\033[0;34m\]\u@\h\[\033[00m\]:\[\033[0;36m\]\W\[\033[00m\]\$(parse_git_branch) $"
# -- #
SELECT `properties`.* FROM `properties` WHERE (
(ACOS(least(1,COS(0.581302161922681)*COS(-1.95199805553677)*COS(RADIANS(properties.lat))*COS(RADIANS(properties.lng))+
COS(0.581302161922681)*SIN(-1.95199805553677)*COS(RADIANS(properties.lat))*SIN(RADIANS(properties.lng))+
SIN(0.581302161922681)*SIN(RADIANS(properties.lat))))*3963.19)
) LIMIT 0, 10
$(document).ready(function() {
$('#report_upload').uploadify({
'uploader' : '/uploadify.swf',
'script': '<%= url_for(:action => :create) %>',
'cancelImg' : '/images/cancel.png',
'auto' : false,
'fileDataName' : 'report[upload]',
'onComplete' : function() {window.location = "<%= users_path %>"},
'scriptData' : {
'report[upload_type]' : function() {$('#report_upload_type').val()}(),
def ask_name
@name = ""
puts "What is your first name?"
@name = gets.chomp
puts "And you middle name?"
@name += " #{gets.chomp}"
puts "And finally, what is your last name?"
@name += " #{gets.chomp}"
puts "So your full name is #{@name}? (y/n)"
@m3talsmith
m3talsmith / git-prompt
Created December 14, 2010 21:59
git-prompt
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"
COLOR_NONE="\[\e[0m\]"
LIGHT_BLUE="\[\033[0;36m\]"
@m3talsmith
m3talsmith / cross sql like scope
Created March 28, 2011 03:19
Like independent across mysql and postgres example
scope :with_name, lambda { |name|
case self.configurations[Rails.env]['adapter']
when 'mysql'
where("name LIKE '%#{name}%'")
when 'postgresql'
where("lower(name) LIKE '%#{name.downcase}%'")
end
}
@m3talsmith
m3talsmith / pending_memberships.rb
Created June 16, 2011 22:47
pending memberships
def pending_memberships
memberships.select {|membership| membership if membership.status == 'pending'}
end