Skip to content

Instantly share code, notes, and snippets.

def import_contacts(file)
contact_file = Tempfile.new(['contact','.xlsx'], :encoding => 'ASCII-8BIT')
contact_file.write(file.tempfile.read)
contacts = CSV.parse(Roo::Excelx.new(contact_file.path).to_csv)
end
def import_contacts(file)
contacts = CSV.parse(Roo::Excelx.new(file.path))
Rails.logger.info(contacts)
end
@bholzer
bholzer / a.js
Last active August 29, 2015 13:57
//Set up modules
(function() {
'use strict';
angular.module('autoMailer', ['ui.router']);
angular.module('autoMailer.providers', []);
angular.module('autoMailer.directives', []);
angular.module('autoMailer.filters', []);
angular.module('autoMailer.controllers', []);
})();
import java.awt.Color;
import java.util.*;
public class ColorUtilities {
public static Color getClosestColorFrom(List<Color> colorList, Color closestTo) {
double shortestDistance = Double.MAX_VALUE;
Color closestColor = closestTo;
for (Color color : colorList) {
if (!color.equals(closestTo)) {
double distance = (closestTo.getRed()-color.getRed())*(closestTo.getRed()-color.getRed())+
var xpathObj = document.evaluate("//a[text()='Birmingham Mountain Radio']/@href/ancestor::h5[1]/following-sibling::div[contains(@class, 'userContent')]", document, null, XPathResult.ANY_TYPE, null)
var result = xpathObj.iterateNext();
while (result) {
if (result.textContent.indexOf('ticket')>=0 && (result.textContent.indexOf('win')>=0 || result.textContent.indexOf('free')>=0)) {
console.log('get dem tickets!');
}
result = xpathObj.iterateNext();
}
(['chain', 'rang', 'watch'].map{|i| "Gold all in my #{i}"}<<"Don't believe me just watch "+"nigga "*3).join(', ')
=> "Gold all in my chain, Gold all in my rang, Gold all in my watch, Don't believe me just watch nigga nigga nigga "
@bholzer
bholzer / gist:7272804
Created November 1, 2013 22:11
Here ya go!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="content-type" />
<title>novemberissue</title>
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" />
</head>
<body alink="" bgcolor="#ffffff" leftmargin="0" link="" marginheight="0" marginwidth="0" style="background-color: rgb(255, 255, 255); color: rgb(0, 0, 0);" text="#000000" topmargin="0" vlink="">
<h3 style="text-align: center;"><span style="color:#A52A2A;">Join the thousands around the world who read Regional Musician!<br />
Click below to start reading today!</span><span style="color:#ff8c00;"><span id="cke_bm_651E" style="display: none;">&nbsp;</span><span id="cke_bm_650E" style="display: none;">&nbsp;</span><span id="cke_bm_640E" style="display: none;">&nbsp;</span><span id="cke_bm_628E" style="display: none;">&nbsp;</span><span id="cke_bm_312E" style="display: none;">&nbsp;</span><span id="ck
.file "test.c"
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "Hello world"
.section .text.startup,"ax",@progbits
.p2align 4,,15
.globl main
.type main, @function
main:
.LFB31:
function Product (options) {
//I like to have all my instance variables in one accessible place
this.priceChangeListeners = new Array();
this.name = null;
this.price = 0.0;
this.upc = null;
this.image_path = null;
// Was: if (options.name == undefined)
// In javascript, many values evaluate to false, including undefined
Backdrop-
-webkit-transition-delay: 0s;
-webkit-transition-duration: 0.15s;
-webkit-transition-property: opacity;
-webkit-transition-timing-function: linear;
background-color: rgb(30, 30, 30);
bottom: 0px;
color: rgb(56, 56, 56);
display: block;