Skip to content

Instantly share code, notes, and snippets.

def self.alphabetized_by_label
initial_hash = all.group_by(&:product_type_name)
initial_hash.each do |key, value|
initial_hash[key] = value.sort{|x,y| x.en_name <=> y.en_name}
end
{}.tap do |final_hash|
initial_hash.keys.sort.each do |key|
final_hash[key] = initial_hash[key]
end
end
@efatsi
efatsi / configuration_types.rb
Created January 10, 2013 17:24
ConfigurationTypes
configuration_types = [
{
:en_name => "Handheld",
:es_name => "De mano",
:position => 1,
:color => "#6b8fbf"
},
{
:en_name => "Lavalier",
:es_name => "De solapa",
@efatsi
efatsi / bash_script
Created December 19, 2012 20:57
Jinglebots cronjob
#! /bin/bash
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
# this line kills the existing speak.rb if one is running
for X in `ps aux | grep speak.rb $1 | awk {'print $2'}`; do kill $X; done
# need to cd to the proper directory for relative path reasons in the ruby code
cd ~/Desktop/jinglebots/robot
ruby speak.rb
Password:
debug3: packet_send2: adding 32 (len 22 padlen 10 extra_pad 64)
debug2: input_userauth_info_req
debug2: input_userauth_info_req: num_prompts 0
debug3: packet_send2: adding 48 (len 10 padlen 6 extra_pad 64)
debug1: Authentication succeeded (keyboard-interactive).
Authenticated to 192.168.7.104 ([192.168.7.104]:22).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
@efatsi
efatsi / index.html
Created November 16, 2012 22:41
Angular.js twitter search
<!doctype html>
<html ng-app="Twitter">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular-resource.min.js"></script>
<script type="text/javascript" src="twitter.js"></script>
<link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css">
</head>
<body>
require 'rubygems'
require 'twitter/json_stream'
require 'json'
TWITTER = {
:username => "letitsnow1415",
:password => "",
:search_terms =>["viget"]
}
@efatsi
efatsi / switch.py
Created November 5, 2012 15:52 — forked from brettbuddin/switch.py
The code that powered the Twerrible Towel (http://twerribletowel.com). It processed 44,610 relevant tweets over the course of 5 days.
#!/usr/bin/env python
import sys
import random
from ctypes import *
from Phidgets.Devices.InterfaceKit import InterfaceKit
from Phidgets.PhidgetException import PhidgetErrorCodes, PhidgetException
try:
kit = InterfaceKit()
kit.openPhidget()
@efatsi
efatsi / log
Created October 29, 2012 15:36
Started POST "/avatars" for 127.0.0.1 at 2012-10-29 11:35:49 -0400
Processing by AvatarsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"VpFNQxYczGC3d/m+HlC8ski3vPCIwJu8xbmb70HpJ7I=", "avatar"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0x007f8b2fae2ec0 @original_filename="vigeclones.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"avatar[image]\"; filename=\"vigeclones.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:/var/folders/j3/zdf8571x7cx8q0mwm2c_r57r0000gn/T/RackMultipart20121029-23346-bh66db>>}, "commit"=>"Add Image"}
Command :: identify -format %wx%h '/var/folders/j3/zdf8571x7cx8q0mwm2c_r57r0000gn/T/vigeclones20121029-23346-1qx7yn.jpg[0]'
Command :: identify -format %m '/var/folders/j3/zdf8571x7cx8q0mwm2c_r57r0000gn/T/vigeclones20121029-23346-1qx7yn.jpg[0]'
Command :: identify -format %m '/var/folders/j3/zdf8571x7cx8q0mwm2c_r57r0000gn/T/vigeclones20121029-23346-1qx7yn.jpg[0]'
Command :: convert '/var/folders/j3/zdf8571x7cx8q0m
Time.zone = ActiveSupport::TimeZone[-6].name
InterviewSlot.new(:start_time => Time.new(2012, 7, 7, 11, 30), :end_time => Time.new(2012, 7, 7, 12, 15))
got: "Saturday July 7th from 9:30 to 10:15 AM"
Time.zone = ActiveSupport::TimeZone[-5].name
InterviewSlot.new(:start_time => Time.new(2012, 7, 7, 11, 30), :end_time => Time.new(2012, 7, 7, 12, 15))
got: "Saturday July 7th from 10:30 to 11:15 AM"
Time.zone = ActiveSupport::TimeZone[-4].name
InterviewSlot.new(:start_time => Time.new(2012, 7, 7, 11, 30), :end_time => Time.new(2012, 7, 7, 12, 15))
#!bash
#
# bash completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#