Skip to content

Instantly share code, notes, and snippets.

View syadlowsky's full-sized avatar

Steve Yadlowsky syadlowsky

View GitHub Profile
@syadlowsky
syadlowsky / New Error:
Created February 27, 2012 17:39
Devise error
/home/steve/.rvm/gems/ruby-1.9.2-p290@tirana/gems/mongo-1.6.0/lib/mongo/util/logging.rb:34:in `instrument': undefined method `level' for #<Mongoid::Logger:0x00000002c9d838> (NoMethodError)
from /home/steve/.rvm/gems/ruby-1.9.2-p290@tirana/gems/mongo-1.6.0/lib/mongo/cursor.rb:467:in `send_initial_query'
from /home/steve/.rvm/gems/ruby-1.9.2-p290@tirana/gems/mongo-1.6.0/lib/mongo/cursor.rb:458:in `refresh'
from /home/steve/.rvm/gems/ruby-1.9.2-p290@tirana/gems/mongo-1.6.0/lib/mongo/cursor.rb:128:in `next'
from /home/steve/.rvm/gems/ruby-1.9.2-p290@tirana/gems/mongo-1.6.0/lib/mongo/db.rb:509:in `command'
from /home/steve/.rvm/gems/ruby-1.9.2-p290@tirana/gems/mongo-1.6.0/lib/mongo/connection.rb:606:in `check_is_master'
from /home/steve/.rvm/gems/ruby-1.9.2-p290@tirana/gems/mongo-1.6.0/lib/mongo/connection.rb:392:in `connect'
from /home/steve/.rvm/gems/ruby-1.9.2-p290@tirana/gems/mongo-1.6.0/lib/mongo/connection.rb:555:in `setup'
from /home/steve/.rvm/gems/ruby-1.9.2-p290@tirana/gems/mongo-1.6.0/lib/mongo/
@syadlowsky
syadlowsky / bridge
Created March 14, 2012 01:51
Ruby standards
Bridge::initialize :api_key => 'abcdefgh' do |bridge|
puts 'connected!'
bridge.get_service("adder") do |service|
service.add(3, 5) do |ret_value|
puts ret_value
end
end
end
@syadlowsky
syadlowsky / gist:2040953
Created March 15, 2012 01:10
CALLOC FREE weirdness
#include<stdlib.h>
// number of floats that fit in L1 cache
#define L1_SIZE 1024
#define L1_MATRIX_ALLOT 512
// number of floats that fit in L2 cache
#define L2_SIZE 8192
// number of floats that fit in L2 cache
#define L3_SIZE 8192
@syadlowsky
syadlowsky / gist:3836797
Created October 4, 2012 22:09
ruby debug
mongo-problem.rb:42
video_group.update!({ 'videos.video_id' => 'video1', :multi => true }, '$set' => {
(rdb:1) s
/home/steve/.rvm/gems/ruby-1.9.3-p194/gems/mongomatic-0.8.2/lib/mongomatic/base.rb:265
update(opts.merge(:safe => true),update_doc)
(rdb:1) s
/home/steve/.rvm/gems/ruby-1.9.3-p194/gems/mongomatic-0.8.2/lib/mongomatic/base.rb:243
if opts[:raise] == true
(rdb:1) s
/home/steve/.rvm/gems/ruby-1.9.3-p194/gems/mongomatic-0.8.2/lib/mongomatic/base.rb:248
postgres=# CREATE LANGUAGE plpythonu;
ERROR: language "plpythonu" already exists
postgres=# \q
postgres@xxxxxx:/home/ubuntu/xxxxxxx/django_utils$ psql geodjango -f voronoi_python.sql
psql:voronoi_python.sql:826: ERROR: language "plpythonu" does not exist
@syadlowsky
syadlowsky / The plan
Last active August 29, 2015 14:19
Migrating to Emacs
The plan
========
1. [http://www.jesshamrick.com/2012/09/10/absolute-beginners-guide-to-emacs/](http://www.jesshamrick.com/2012/09/10/absolute-beginners-guide-to-emacs/)
2. [http://www.gnu.org/software/emacs/manual/](http://www.gnu.org/software/emacs/manual/) (just the main section)
3. [http://bling.github.io/blog/2013/10/27/emacs-as-my-leader-vim-survival-guide/](http://bling.github.io/blog/2013/10/27/emacs-as-my-leader-vim-survival-guide/)
4. [http://www.gnu.org/software/emacs/manual/eintr.html](http://www.gnu.org/software/emacs/manual/eintr.html)
5. [https://github.com/ronuchit/Settings/blob/master/.emacs](https://github.com/ronuchit/Settings/blob/master/.emacs)
6. [http://www.jesshamrick.com/2012/09/18/emacs-as-a-python-ide/](http://www.jesshamrick.com/2012/09/18/emacs-as-a-python-ide/)
c_0 = -0.969474842881623111168210
c_2 = 4.364528972627628178315717
c_4 = -2.422793242101592081638728
function fast_cos(t::Real)
# Computes cos(pi*t) using a Chebyshev approximation.
# This approximation is minimax optimal on [-1, 1].
# By scaling by pi, we find an optimal approximation on
# the entire range of cos(x). Because cos(x - pi) = -cos(x),
# we can take the remainder with 2, and shift [0, 2] |-> [-1, 1],
class foo:
def __init__(self, a={}):
self.a = a
one = foo()
two = foo()
two.a["a"] = 2
print one.a
SIGMA = args.sigma
NUM_RAND_FEATURES = args.num_rand_features
data_hdf5 = h5py.File(args.filename,'r+')
d = data_hdf5['train']['x'][0].shape[0]
n = len(data_hdf5['train']['x'])
train_y = np.array(data_hdf5['train']['t'])
features = np.array(data_hdf5['train']['x'])
simple.logistic = function(x, y, w, iters=30, l1_penalty=0) {
d = ncol(x)
n = nrow(x)
x_c = colMeans(x)
x = (x - matrix(rep(x_c, n), nrow=n, byrow = T))
x_s = sqrt(colMeans(x^2))
x = (x / matrix(rep(x_s, n), nrow=n, byrow = T))
beta = rep(0,d)
p = weighted.mean(y, w = w)
beta_0 = log(p) - log(1-p)