This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/profiler.rb | |
class Profiler | |
def self.prof(file_name) | |
RubyProf.start | |
yield | |
results = RubyProf.stop | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_url(string): | |
""" | |
Checks if the given string starts with 'http(s)'. | |
""" | |
try: | |
return string.startswith('http://') or string.startswith('https://') | |
except AttributeError: | |
return False |