Skip to content

Instantly share code, notes, and snippets.

ruby """
def photo_gps_list
photos_dir = File.absolute_path('assets/photos/')
photos_url = '/assets/photos/'
photos = Dir.entries(photos_dir).select { |filename| filename if filename.end_with?('jpg') }
result = photos.map do |photo|
photo_exif = EXIFR::JPEG.new(photos_dir + '/' + photo)
puts "#{photo}, #{photo_exif.exif.date_time_original}, #{photo_exif.gps.longitude}, #{photo_exif.gps.latitude}" unless photo_exif.gps.nil?
end
end
pulseaudio -k
export DISPLAY=:0
xset dpms on
xset dpms force on
i3-msg workspace 5
def func(string1, string2, block)
string = string1 + " " + string2
puts "\#1: #{string}"
block.call(string, 'here')
end
# => :func
proc = Proc.new { |a, b| puts "\#2: #{a}, #{b}" }
func "calling", "function", proc
# #1: calling function
@romanblanco
romanblanco / android.sh
Last active March 23, 2020 21:10
android adb
adb devices -l # make sure your gadget is listed
adb shell # run a shell there
su # become the root (don't miss confirmation request!)
mount -o remount,rw /system # allow to write
vi /system/etc/hosts ## edit the file in place - do what you whant, then <ESC>:wq ##
mount -o remount,ro /system # get things back to normal
exit # unroot
nslookup YourBlockedAdSite.Net # check if it works
exit # good bye
# the dialog had one text_box and one text_area before editing.
# in the dialog editor the text_area was removed.
# now after hitting 'save' button, i'm getting to the api:
From: /home/rblanco/devel/manageiq-api/app/controllers/api/service_dialogs_controller.rb @ line 33 Api::ServiceDialogsController#edit_resource:
31: def edit_resource(type, id, data) # type: :service_dialogs, id: 10000000000056, data: {"label"=>"testing", "content"=>{"dialog_tabs"=>[{"id"=>"10000000000841", "created_at"=>"2017-12-07T11:50:57Z", "updated_at"=>"2017-12-07T11:50:5
32: binding.pry
=> 33: service_dialog = resource_search(id, type, Dialog)
34: begin
@romanblanco
romanblanco / test.rb
Created December 4, 2017 14:34
example
=> #<DialogFieldDropDownList:0x00563c68b6d3c0
id: 10000000005919,
name: "dropdown_list_1",
description: "",
type: "DialogFieldDropDownList",
data_type: "string",
notes: nil,
notes_display: nil,
display: "edit",
display_method: nil,
@romanblanco
romanblanco / dialog_export.yml
Created August 24, 2017 12:26
Dialog example
---
- description:
buttons: submit,cancel
label: uspto_provision_vm_jboss_eap
blueprint_id:
dialog_tabs:
- description: VM Details
display: edit
label: VM Details
display_method:
@romanblanco
romanblanco / create_resource.rb
Last active January 15, 2018 16:26
Dialog saving debugging
Log for creating Tag Control containing dialog
D, [2018-01-12T15:47:28.286904 #15784] DEBUG -- : PostgreSQLAdapter#log_after_checkin, connection_pool: size: 5, connections: 5, in use: 1, waiting_in_queue: 0
I, [2018-01-12T15:48:12.497772 #15784] INFO -- : Started POST "/api/service_dialogs/10000000000066" for ::1 at 2018-01-12 15:48:12 +0100
I, [2018-01-12T15:48:12.551593 #15784] INFO -- : Processing by Api::ServiceDialogsController#update as JSON
I, [2018-01-12T15:48:12.551727 #15784] INFO -- : Parameters: {"c_id"=>"10000000000066"}
D, [2018-01-12T15:48:12.552314 #15784] DEBUG -- : Cache read: eeacccda3fd1faab0d74ce164382d4b6
D, [2018-01-12T15:48:12.552779 #15784] DEBUG -- : Cache read: eeacccda3fd1faab0d74ce164382d4b6
describe Mixins::CheckedIdMixin do
describe '#find_records_with_rbac' do
# include tested mixin
let(:mixin) { Object.new.tap { |s| s.singleton_class.send(:include, described_class) } }
# TODO create user with rights to access vm_1 and vm_2
let(:user_role) { FactoryGirl.create(:miq_user_role) }
let(:group) { FactoryGirl.create(
:miq_group,
:miq_user_role => user_role)
}
# http://chartkick.com/
require 'lastfm-client'
#require 'ap'
#require 'pry'
#require 'json'
LastFM.api_key = ''
LastFM.client_name = 'stats'