Skip to content

Instantly share code, notes, and snippets.

Odoo Server Error
Traceback (most recent call last):
File "/home/korakot/apps/printedmint/pm2/odoo/addons/base/models/ir_ui_view.py", line 640, in apply_inheritance_specs
source = apply_inheritance_specs(source, specs_tree,
File "/home/korakot/apps/printedmint/pm2/odoo/tools/template_inheritance.py", line 229, in apply_inheritance_specs
raise ValueError(
ValueError: Element '<xpath expr="//div/div/div[2]">' cannot be located in parent view
# lib/tasks/some_task.rake
require 'profiler'
namespace :some_task do
task :apple do
# byebug
Profiler::prof("import") do
# Your slow code here
sleep 2
# lib/profiler.rb
class Profiler
def self.prof(file_name)
RubyProf.start
yield
results = RubyProf.stop
@korakotlee
korakotlee / blog.md
Last active December 31, 2019 15:11
test

Test Gistlog

Dev blog from gist.

@korakotlee
korakotlee / rover.rb
Created July 18, 2019 17:48
Ruby Mars Rover
class Rover
# attr_reader :x, :y, :direction
def initialize(x, y, dir)
@x = x
@y = y
@dir = dir
end
def to_s
puts "#{@x} #{@y} #{@dir}"
@korakotlee
korakotlee / bubblesort.rb
Created July 8, 2019 15:43
ruby bubble sort
def bubble_sort(list)
return list if list.size <= 1
loop do
sorted = true
index_right = 2
0.upto(list.size-index_right) do |i|
if list[i] > list[i+1]
list[i], list[i+1] = list[i+1], list[i]
sorted = false
end
@korakotlee
korakotlee / insertion_sort.rb
Created July 8, 2019 15:23
ruby insertion sort
def insertion_sort(array)
final = []
final << array.shift
for i in array
final_index = 0
while final_index < final.length
if i <= final[final_index]
final.insert(final_index,i)
break
elsif final_index == final.length-1
@korakotlee
korakotlee / quicksort.rb
Created July 6, 2019 02:36
ruby quicksort
def quicksort(a, first, last)
if first < last
p_index = partition(a, first, last)
quicksort(a, first, p_index-1)
quicksort(a, p_index+1, last)
end
return a
end
def partition(a, first, last)
@korakotlee
korakotlee / ChatHeadService.java
Created April 30, 2019 13:27
ChatHeadService for Flutter platform channel
package com.korakotlee.korspeed;
import android.app.Service;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.os.IBinder;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
@korakotlee
korakotlee / LocationPlugin.java
Created April 30, 2019 13:19
LocationPlugin for Flutter
package com.lyokone.location;
import android.Manifest;
import android.app.Activity;
import android.provider.Settings;
import android.content.IntentSender;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationManager;