Assuming this directory structure:
project
|-- src
| +-- (source files)
+-- html
+-- (generated html)
import sys | |
def negVector(lst): | |
return [-x for x in lst] | |
def addVectors(l1, l2): | |
return [l1[i] + l2[i] for i in range(len(l1))] | |
def multVectors(l1, l2): | |
return [l1[i] * l2[i] for i in range(len(l1))] |
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" |
Assuming this directory structure:
project
|-- src
| +-- (source files)
+-- html
+-- (generated html)
class Hash | |
def deep_sort | |
Hash[sort.map {|k, v| [k, v.is_a?(Hash) ? v.deep_sort : v]}] | |
end | |
end |
#!/bin/sh | |
export DISPLAY=:0.0 | |
sudo killall chrome | |
google-chrome $1 & | |
sleep 2 | |
xdotool key F11 |
# | |
# Usage: ruby score_subreddit.rb <list of subreddits> | |
# | |
# Computes the Flesch-Kincaid grade level of the last 25 comments of the given subreddits. | |
# | |
# For example: | |
# > ruby score_subreddit.rb science worldnews funny | |
# science: 8.33 | |
# worldnews: 9.71 | |
# funny: 5.32 |
require 'mechanize' | |
agent = Mechanize.new | |
language_regex = Regexp.new(/]\r\n\t\t\t\t\t\t([0-9,]*)(\.| )/) | |
index_page = agent.get('http://www.ethnologue.com/country_index.asp?place=all') | |
index_page.links_with(:href => /show_country.asp/).each do |country_link| | |
country = country_link.text().strip() | |
speakers = [] |
limit = 1000 | |
nums = (1..limit).to_a | |
([1] + nums).each do |a| | |
lucky_num = nums[a] | |
unlucky_nums = nums.values_at(* nums.each_index.select {|i| (i+1) % lucky_num == 0}) | |
if unlucky_nums.size == 0 | |
break | |
else |
[num_features, num_states] = size(backup_states_phi); % [22, 92] | |
num_actions = size(R{1}{1}); % 40 | |
num_blocks = block_idx; % 7 | |
mu0 = ones(num_states, 1) / num_states; | |
% cvx_solver sedumi | |
cvx_begin | |
variable theta(num_features) | |
variable V(num_states, num_blocks) | |
minimize sum(dot(mu0, (transpose(theta) * backup_states_phi))) + C * norm(theta) |
if (map.getPlayer().getX()>10) me.move('right'); | |
if (map.getPlayer().getX()<10) me.move('left'); | |
if (map.getPlayer().getY()>10) me.move('down'); | |
if (map.getPlayer().getY()<10) me.move('up'); |