Skip to content

Instantly share code, notes, and snippets.

HKEY_LOCAL_MACHINE\ SOFTWARE\ Microsoft\ Windows NT\ CurrentVersion\ ProfileList
@taiar
taiar / prefix_sorting.rb
Created December 19, 2019 00:55
Prefix sorting algorithm
array = [12, 3, 12, 8, 4, 5, 25]
def sortz(arr)
sorted = arr.sort
sol = []
while sorted != sol
max = arr.max
imax = arr.index(max)
arr = (arr[0..imax].reverse + arr[(imax + 1)..-1]).reverse
sol.unshift(arr[-1])
@taiar
taiar / install-quake3.sh
Created December 18, 2019 13:43 — forked from simonewebdesign/install-quake3.sh
Install Quake 3: Arena on a mac
#!/bin/bash
# Install Quake 3: Arena on a mac
# Copyright (c) 2016 simonewebdesign
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Rake::Task['db:migrate'].enhance do
tables = ActiveRecord::Base.connection.tables
all_foreign_keys = tables.flat_map do |table_name|
ActiveRecord::Base.connection.columns(table_name).map {|c| [table_name, c.name].join('.') }
end.select { |c| c.ends_with?('_id') }
indexed_columns = tables.map do |table_name|
ActiveRecord::Base.connection.indexes(table_name).map do |index|
index.columns.map {|c| [table_name, c].join('.') }
end
mysql -u root -proot -e "SELECT table_name, table_rows FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = \"DATABASE\";"
css = [[1, 60] ,[3, 95]]
customers = [[1, 90], [2, 20], [3, 70], [4, 40], [5, 60], [6, 10]]
vacant_css = [2, 4]
def can_answer?(cs, customer)
cs[1] >= customer[1]
end
def most_free(candidates, allocation)
E, [2019-05-23T18:07:44.412121 #14008] ERROR -- : [4bb10f1e-6240-4466-8a04-127bfd30f6f6] no implicit conversion of nil into String
I, [2019-05-23T18:07:44.412676 #14008] INFO -- : [4bb10f1e-6240-4466-8a04-127bfd30f6f6] method=GET path=/ format=html controller=DashboardsController action=index status=500 error='ArgumentError: When assigning attributes, you must pass a hash as an argument.' duration=5925.77 view=0.00 db=177.01
F, [2019-05-23T18:07:44.413395 #14008] FATAL -- : [4bb10f1e-6240-4466-8a04-127bfd30f6f6]
F, [2019-05-23T18:07:44.413482 #14008] FATAL -- : [4bb10f1e-6240-4466-8a04-127bfd30f6f6] ArgumentError (When assigning attributes, you must pass a hash as an argument.):
F, [2019-05-23T18:07:44.413551 #14008] FATAL -- : [4bb10f1e-6240-4466-8a04-127bfd30f6f6]
F, [2019-05-23T18:07:44.413620 #14008] FATAL -- : [4bb10f1e-6240-4466-8a04-127bfd30f6f6] app/services/representers/product_representation.rb:9:in `initialize'
F, [2019-05-23T18:07:44.413710 #14008] FATAL -- : [4bb10f1e-6240-4466-8a04-127bfd
@taiar
taiar / find.rb
Last active May 14, 2019 16:57
Ruby script to find "strange" characters on Excel XLSX documents.
# Installation: requires loofah gem
#
# Usage: ruby find.rb name_of_the.xlsx
require 'loofah'
require 'fileutils'
TMP_DIR = 'tmp'
ASCII_TRESHOLD = 255
FILE_EXT = '.xml'
@taiar
taiar / list.rb
Last active March 29, 2020 17:26
Get list of new queues that might be created
[
'/home/taiar/***/app/workers/',
'/home/taiar/***/app/workers/accounts/',
'/home/taiar/***/app/workers/cards/',
'/home/taiar/***/app/workers/consumers/'
].each do |path|
files = Dir.glob("#{path}*").collect { |file_path| File.basename(file_path) }
files.select! { | f | File.extname(f) == '.rb' }
files.each { | e | require "#{path}#{e}" }
end
@taiar
taiar / rails_error.log
Created October 8, 2018 13:44
Daily rails error
-- Control frame information -----------------------------------------------
c:0118 p:---- s:0618 e:000617 CFUNC :binding
c:0117 p:0015 s:0615 e:000612 BLOCK /home/taiar/.rvm/gems/ruby-2.3.1@gdce/gems/interception-0.5/lib/cross_platform.rb:68 [FINISH]
c:0116 p:---- s:0610 e:000609 IFUNC :name
c:0115 p:---- s:0608 e:000607 CFUNC :map
c:0114 p:0021 s:0605 E:001238 BLOCK (pry):2 [FINISH]
c:0113 p:---- s:0602 e:000601 CFUNC :map
c:0112 p:0022 s:0599 E:001360 METHOD /home/taiar/.rvm/gems/ruby-2.3.1@gdce/gems/activerecord-4.2.10/lib/active_record/relation/delegation.rb:46
c:0111 p:0008 s:0592 E:0016c0 EVAL (pry):2 [FINISH]
c:0110 p:---- s:0590 e:000589 CFUNC :eval