Skip to content

Instantly share code, notes, and snippets.

# /etc/init/workers.conf - manage a set of Sidekiqs
# This example config should work with Ubuntu 12.04+. It
# allows you to manage multiple Sidekiq instances with
# Upstart, Ubuntu's native service management tool.
#
# See sidekiq.conf for how to manage a single Sidekiq instance.
#
# Use "stop workers" to stop all Sidekiq instances.
# Use "start workers" to start all instances.
<%= f.fields_for :new_drugs do |cf| %>
<div class="row" style="margin-bottom:5px">
<div class="span1"><%= cf.text_field :atc, class: 'xsmall-input' %></div>
<div class="span3"><%= cf.text_field :description %></div>
<div class="span3"><%= cf.text_field :reason %></div>
<div class="span1"><%= cf.text_field :cases_prior, class: 'xsmall-input' %></div>
<div class="span1"><%= cf.text_field :cases_expected, class: 'xsmall-input' %></div>
<div class="span2"><%= cf.text_field :reason, class: 'small-input' %></div>
</div>
<% end %>
@panmari
panmari / postgresql_random_retrieve.rb
Last active May 11, 2018 10:59
Benchmark of various methods to retrieve a random record from a table using ActiveRecord and a Postgresql db behind.
require 'benchmark'
# Disable logging if in development/test mode
ActiveRecord::Base.logger = nil
model_name = Icd
N = 100
Benchmark.bm(11) do |x|
x.report('ruby rand') { N.times { model_name.offset(rand(model_name.count)).first } }
func (mat *T) MulVec4(v *vec4.T) vec4.T {
return vec4.T{
mat[0][0]*v[0] + mat[1][0]*v[1] + mat[2][0]*v[2] + mat[3][0]*v[3],
mat[0][1]*v[0] + mat[1][1]*v[1] + mat[2][1]*v[2] + mat[3][1]*v[3],
mat[0][2]*v[0] + mat[1][2]*v[1] + mat[2][2]*v[2] + mat[3][2]*v[3],
mat[0][3]*v[0] + mat[1][3]*v[1] + mat[2][3]*v[2] + mat[3][3]*v[3],
}
}
// Strangely, this is the slowest of the three.
func BenchmarkMulVec4(b *testing.B) {
m1 := &T{vec4.T{0.38016528, -0.0661157, -0.008264462, -0}, vec4.T{-0.19834709, 0.33884296, -0.08264463, 0}, vec4.T{0.11570247, -0.28099173, 0.21487603, -0}, vec4.T{18.958677, -33.471073, 8.066115, 0.99999994}}
b.ResetTimer()
for i := 0; i < b.N; i++ {
v := vec4.T{1, 1.5, 2, 2.5}
v_1 := m1.MulVec4(&v)
m1.MulVec4(&v_1)
}
}
@panmari
panmari / gdb
Created September 30, 2014 17:40
Loading Go Runtime support.
No source file named /home/mazzzy/go_workspace/gort/src/main.go.
No source file named /home/mazzzy/go_workspace/gort/src/intersectables/csg/node.go.
445,534 2-environment-cd /home/mazzzy/go_workspace/simple
445,534 2^done
445,535 (gdb)
445,536 3-gdb-set breakpoint pending on
445,536 3^done
445,537 (gdb)
445,540 4-gdb-set detach-on-fork on
445,540 4^done
445,540 (gdb)
445,544 5-enable-pretty-printing
@panmari
panmari / downloader.patch
Created May 19, 2014 15:46
patch for downloader
diff --git a/lib/tasks/update_wiki/Downloader.rb b/lib/tasks/update_wiki/Downloader.rb
index bb58022..93a8ba5 100644
--- a/lib/tasks/update_wiki/Downloader.rb
+++ b/lib/tasks/update_wiki/Downloader.rb
@@ -32,20 +32,24 @@ class Downloader
#calculate percentage
@pct = (@c.to_f/@length.to_f*100).round(3)
#check if article already exists
- check = @client.query("SELECT * FROM pages WHERE page_id = #{name["page_id"]}").count
- unless check == 1
@panmari
panmari / gist:6579977
Last active December 23, 2015 04:19
jrtr getting started notes

General tips

  • Install the source/javadoc for eclipse built in documentation (right click on project -> Maven -> download source).
  • Manually add the documentation for vecmath (simple project -> maven dependancies -> vecmath-1.3.1.jar rightclick -> properties -> add http://download.java.net/media/java3d/javadoc/1.5.0/ under javadoc location path.

Linux

Nvidia graphics card

@panmari
panmari / elastic_search_parallel
Created August 28, 2013 09:14
Starting two queries to the elasticsearch server through the Tire gem. Even though the long, complicated query starts before the short one, the short one is returned first.
# try this in a rails environment, that has the Indexing module loaded. (medcode, orangeproton)
search_queries = ["Ein sehr komplizierter query, der sehr lange zum ausfuhren braucht", "kurz"] # !sic
threads = []
search_queries.each do |string|
threads << Thread.new(string) do |query|
puts "started #{query}"
Indexing.elastic_find_all(string, 'icd', '2012', 'ch', 'de')
puts "finished #{query}"
end