Skip to content

Instantly share code, notes, and snippets.

View srih4ri's full-sized avatar
🔥
Lighting things on fire, brb

Srihari srih4ri

🔥
Lighting things on fire, brb
View GitHub Profile
............
Retrieval is half of what Redis does best.
Before you put any data into Redis, you have to figure out how you want to get it back out. How you retrieve data is directly related to which of the five Redis data types you’ll use to store it.
To review, the five Redis data types are: strings, lists, hashes, sets, and sorted sets.
Start by asking yourself what kind of results you want from your data.
What do you need to retrieve?
["http://dev.ehq.local/admin/reports/status?key=reports%3Astore%3Ainformation_report%3A9%3A319%3Alast_30_days%3A2014-02-05+00%3A00%3A00+%2B1100%3A2014-03-07+00%3A00%3A00+%2B1100%3Atrue%3A%7C%7C%7C%7C%7C%3A5"]
____________________________________________________________________________________________________
["set_reports_session_prefixWriting {} to 419413b710fd1ae8e17483c37c835ad2:Admin::ReportsController "]
____________________________________________________________________________________________________
["At 3"]
____________________________________________________________________________________________________
["find_assigned_projectsWriting [\"319\"] to 419413b710fd1ae8e17483c37c835ad2:Admin::ReportsController:assigned_project_ids "]
____________________________________________________________________________________________________
["At 3"]
____________________________________________________________________________________________________
#!/usr/bin/env ruby
file = "/home/srih4ri/code/rm_current_clem/to_delete.txt"
require "dbus"
sesbus = DBus.session_bus
clem_service = sesbus["org.mpris.clementine"]
clem_object = clem_service.object "/Player"
clem_object.introspect
clem_iface = clem_object['org.freedesktop.MediaPlayer']
meta = clem_iface.GetMetadata
file_loc = meta[0]['location'].split('file://').last
desc 'Run Devise tests for all ORMs.'
task :tests do
Dir[File.join(File.dirname(__FILE__), 'test', 'orm', '*.rb')].each do |file|
orm = File.basename(file).split(".").first
system "rake test DEVISE_ORM=#{orm}"
end
end
task :default => :tests
@srih4ri
srih4ri / update_plugin_assets.md
Created November 5, 2012 16:10
Script to copy fedena plugin's assets to public dir on file change ( Using inotify-tools )

Copy the following into a shell script in fedena's root folder, give it executable permissions and run as :

./update_plugin_assets.sh vendor/plugins/my_awesome_plugin
#!/bin/sh
plugin_dir=$1
while inotifywait -r -e modify $plugin_dir ; do
@srih4ri
srih4ri / ruby-tests.rake
Created November 2, 2012 18:52
Ruby-tests for ruby-roxml
task :test do
require 'rake/runtest'
$: << 'lib' << '.'
Rake.run_tests 'test/unit/*_test.rb'
end
namespace :test do
desc "Test ROXML under the Nokogiri parser"
task :nokogiri do
@srih4ri
srih4ri / auth_db.rb
Created September 5, 2011 18:01
A ruby script being called by mod_authnz_external
#!/usr/bin/ruby
require 'rubygems'
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => "mysql",
:host => "localhost",
:username => "myuser",
:password => "mypass",
:database => "somedatabase"
@srih4ri
srih4ri / checkip
Created July 17, 2011 15:08
See what the internet calls you. Wrote for giving my IP to friends for slimevolley.
curl -s http://checkip.dyndns.com/|cut -d ":" -f 2|cut -d "<" -f 1
#You might want to alias this thing to something shorter. `checkip` in my case.
@srih4ri
srih4ri / CheckPassword.rb
Created June 14, 2011 14:34
CheckPassword.rb
#!/usr/bin/env ruby
module PasswordChecker
def check_valid?
if length > 1
(length/2).times { |i|
return false if (self[(i+1..length)].start_with? self[(0..i)])
}
(self[(1..length)]).check_valid?
else
return true
@srih4ri
srih4ri / application_helper.rb
Created March 20, 2011 14:04
Call it with <%= stylesheet_link_tag(*get_stylesheets) %> in your layouts file
def get_stylesheets
styles_path = "#{Rails.root}/public/stylesheets"
controller_name = controller.controller_path
action_name = controller.action_name
if File.exists? "#{styles_path}/#{controller_name}/#{action_name}.css"
"#{controller_name}/#{action_name}"
elsif ["create","edit","update"].include? action_name and File.exists? " #{styles_path}/#{controller_name}/new.css"
"#{controller_name}/new"
end
end