Skip to content

Instantly share code, notes, and snippets.

View oshanz's full-sized avatar
🌴
On vacation

Oshan Wisumperuma oshanz

🌴
On vacation
View GitHub Profile
@oshanz
oshanz / 795945.geojson
Last active October 30, 2020 11:29
ES 7.9 indexing error
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@oshanz
oshanz / PHP – Google Currency Converter
Created April 9, 2014 10:28
PHP – Google Currency Converter
<?php
function currency_convert($from,$to,$amount) {
$string = "1".$from."=?".$to;
$google_url = "http://www.google.com/ig/calculator?hl=en&q=".$string;
$result = file_get_contents($google_url);
$result = explode('"', $result);
$converted_amount = explode(' ', $result[3]);
$conversion = $converted_amount[0];
$conversion = $conversion * $amount;
$conversion = round($conversion, 2);
@oshanz
oshanz / worst file
Created September 7, 2020 06:44
code quality
git log --format=format: --name-only | egrep -v '^$' | sort | uniq -c | sort -rg | head -10
@oshanz
oshanz / ruby on fedora.md
Last active August 25, 2020 13:03
ruby on fedora

for ruby 2.2.10

dnf install compat-openssl10-devel --allowerasing

for ruby 2.6.6

$ openssl version

remove compat-openssl10*

dnf install openssl-devel

https://stackoverflow.com/questions/62256277/geojson-to-elasticsearch-unable-to-tessellate-shape
https://stackoverflow.com/questions/55587629/failed-to-create-valid-geo-shape/55588509#55588509
@oshanz
oshanz / hard disk clicking noice.md
Created August 3, 2020 12:12
hard disk clicking noice
  • check if these values change after sound smartctl -A /dev/sda|grep -E 'Power_Cycle_Count|Load_Cycle_Count'

  • acoustic level sudo hdparm -M /dev/sda /dev/sda: acoustic = 254 (128=quiet ... 254=fast)

  • see current value sudo hdparm -B /dev/sda

@oshanz
oshanz / capistrano.rb
Last active July 23, 2020 12:37
capistrano clear cache
namespace :cachestore do
desc "clear cache store"
task :clear, roles: [:app] do
with rails_env: fetch(:rails_env) do
within current_path do
execute :bundle, :exec, "rake cache:clearstore"
end
end
end
end

http://robots.thoughtbot.com/post/47202759358/using-gdb-to-inspect-a-running-ruby-process

That’s not a great thing to have to say, is it? However, I bet you’ve said it before and may not have immediately know why.

With liberal use of puts and maybe pry, you can figure out what a problem might be next time you run it, but sometimes you need to figure out what that problem is right now.

As it turns out, and I know this is a shocker, Ruby processes are just regular processes. They can be debugged with gdb.

Having recently had the need to find out why a job of mine was running particularly slowly, I found out about this lovely tool the hard way: frantic googling. I found some very useful functions for gdb in a blog post by Rasmus on Ruby callstacks.

curl -GET "http://localhost:9200/_cluster/allocation/explain?pretty"
curl -XPOST 'localhost:9200/_cluster/reroute?retry_failed'