Skip to content

Instantly share code, notes, and snippets.

require 'fastercsv'
require 'csv'
require 'net/http'
require 'sanitize'
#CSV_FILE_PATH = File.join(File.dirname(__FILE__), 'c2i.csv')
CSV_FILE_PATH = File.join('/tmp', 'Computers_Accessories_Master.csv')
=begin
@wogsland
wogsland / badlines.pl
Created January 21, 2013 01:28
Have a ginormous CSV file with a bad line in it? Use this rather than some stupid program like excel which will take 5 minutes to open the file and then only gives you access to a small portion of it.
#!/usr/bin/perl
open (FOO, "file_with_bad_line.csv") ||
die "ERROR Unable to open test: $!\n";
open (BAR, ">badlines.csv");
$rowcount=0;
while (<FOO>) {
$rowcount++;
@wogsland
wogsland / shorten_whitespace.pl
Last active December 23, 2015 19:59
This short script takes a file with too much whitespace (broken.txt) and shortens each section of multiple spaces to a single space. Useful if you're sent a hybrid fixed-width/space-delimited file.
#-------------------------------------------------------------------------
# This script fixes an almost fixed width file farked on a number of lines.
# It outputs a nicer space-delimited one.
#-------------------------------------------------------------------------
#!/usr/local/bin/perl
print "Starting...\n";
$rowcount = 0;
open(MRFILE, "broken.txt");
class RubyParser
#Creates a hash table as the parser object given a file name.
def initialize(filename)
#open the file
@filename = filename
toparse = File.open(@filename,"r")
#build the hash table
@sections = Hash.new
@wogsland
wogsland / gist:2f17423354f6c0aa99b9
Created May 21, 2014 00:50
highcharts barchart example
<?php echo HighRoller::setHighChartsLocation("highcharts.js");?>
<!-- $data is an array of 4 arrays: dates & vars on those dates -->
<?// Bar Chart
$barchart = new HighRollerAreaChart();
$barchart->chart->renderTo = 'history';
$barchart->chart->zoomType = 'x';
$barchart->title->text = 'History';
$barchart->yAxis->stackLabels = 'true';
@wogsland
wogsland / P1Info.java
Created May 21, 2014 01:16
1999 - a trip down memory lane . . . here's a CS assignment where we were basically finding mp3s to rip off around the internet. Kind of hilarious in context. This was 2 months before Napster came out.
/**
* Class p1info.java -- an information file for assignment 1
* in CS4812. This file is formatted as a .java file, with
* extensive comment fields, so that it might be harmlessly
* added to a project file in most popular IDEs. This allows
* for more convenient consultation of the assignment
* specifications during development.
*
* @author <A HREF="mailto:dagon@cc.gatech.edu">David Dagon</A>
* @version 1.1
@wogsland
wogsland / BaseModel.php
Last active August 29, 2015 14:02
Laravel: quickly build models from an existing DB. Put the files in app/models directory, modify build_models.php to your DB info and then run it on the command line. After your models are created, build_models.php can be deleted. The build_models.php script is also be fairly simple to modify to create the controllers for your particular applica…
<?php
use Rhumsaa\Uuid\Uuid;
class BaseModel
extends Eloquent
{
// Make sure errors are available for when validation fails
public $errors;
@wogsland
wogsland / config.cson
Created July 11, 2014 20:49
Atom config.cson
'exception-reporting':
'userId': 'd92042ac-d007-9956-fb27-59debd2b80e6'
'welcome':
'showOnStartup': false
'metrics':
'userId': '09f13261ac75c440adcbafbb995b6d88ea8c5468'
'editor':
'fontSize': 12
'showIndentGuide': true
'showInvisibles': true
@wogsland
wogsland / .profile
Last active February 26, 2020 10:47
OS X .profile
# The next line updates PATH for the Google Cloud SDK.
#source '/Users/wogsland/Projects/google-cloud-sdk/path.bash.inc'
# The next line enables shell command completion for gcloud.
#source '/Users/wogsland/Projects/google-cloud-sdk/completion.bash.inc'
## Aliases
alias ls='ls -la'
alias grep='grep -r -n'
alias composer='php ~/composer.phar'
@wogsland
wogsland / mc_conn_tester.pl
Created August 21, 2014 16:23
Memcache Connection Tester
#! /usr/bin/perl
# Written by Dormando.
# PUBLIC DOMAIN.
# No guarantees it won't eat your cat.
# From http://consoleninja.net/code/memcached/mc_conn_tester.pl via https://code.google.com/p/memcached/wiki/Timeouts
use warnings;
use strict;
use IO::Socket::INET;