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
| require "active_record" | |
| puts "AR Version: #{ActiveRecord::VERSION::MAJOR}" | |
| ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") | |
| ActiveRecord::Schema.define do | |
| create_table :languages do |t| | |
| t.string :type | |
| 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
| class Order | |
| def initialize | |
| @line_items = [] | |
| end | |
| def add_line_item(line_item) | |
| @line_items << line_item | |
| end | |
| def total |
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
| <IfModule mod_rewrite.c> | |
| Options +FollowSymLinks | |
| RewriteEngine On | |
| RedirectMatch ^/$ http://www.longurl.com | |
| RewriteBase / | |
| RewriteCond %{REQUEST_FILENAME} !-f | |
| RewriteCond %{REQUEST_FILENAME} !-d | |
| RewriteRule ^([0-9A-Za-z]+)/?$ /yourls-go.php?id=$1 [L] | |
| RewriteRule ^([0-9A-Za-z]+)\+/?$ /yourls-infos.php?id=$1 [L] | |
| RewriteRule ^([0-9A-Za-z]+)\+all/?$ /yourls-infos.php?id=$1&all=1 [L] |
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
| @Override | |
| @TargetApi(11) | |
| public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { | |
| super.onCreateOptionsMenu(menu, inflater); | |
| inflater.inflate(R.menu.fragment_cheng_yu_list, menu); | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { | |
| MenuItem searchItem = menu.findItem(R.id.menu_item_search); | |
| SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); |
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.benjamintanweihao.bookeesg.product; | |
| import com.benjamintanweihao.bookeesg.R; | |
| import android.graphics.Bitmap; | |
| import android.os.AsyncTask; | |
| import android.os.Bundle; | |
| import android.support.v4.app.Fragment; | |
| import android.support.v4.app.FragmentActivity; | |
| import android.support.v4.app.FragmentManager; |
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.benjamintanweihao.bookeesg.product; | |
| import com.benjamintanweihao.bookeesg.R; | |
| import android.graphics.Bitmap; | |
| import android.os.AsyncTask; | |
| import android.os.Bundle; | |
| import android.support.v4.app.Fragment; | |
| import android.support.v4.app.FragmentActivity; | |
| import android.support.v4.app.FragmentManager; |
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
| # Video: http://rubyhoedown2008.confreaks.com/08-chris-wanstrath-keynote.html | |
| Hi everyone, I'm Chris Wanstrath. | |
| When Jeremy asked me to come talk, I said yes. Hell yes. Immediately. But | |
| then I took a few moments and thought, Wait, why? Why me? What am I supposed | |
| to say that's interesting? Something about Ruby, perhaps. Maybe the | |
| future of it. The future of something, at least. That sounds | |
| keynote-y. | |
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
| defmodule Crypto do | |
| def md5(s) do | |
| list_to_binary(Enum.map(bitstring_to_list(:crypto.md5(s)), fn(x) -> integer_to_binary(x, 16) end)) | |
| end | |
| 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
| # brew install mahout | |
| # export MAHOUT_DIR="/usr/local/Cellar/mahout/0.8/" | |
| puts "#{ENV['MAHOUT_DIR']}libexec/*.jar" | |
| Dir.glob("#{ENV['MAHOUT_DIR']}/libexec/*.jar").each { |d| require d } | |
| MahoutFile = org.apache.mahout.cf.taste.impl.model.file | |
| model = MahoutFile.FileDataModel.new(java.io.File.new("data.csv")) | |
| MahoutSimilarity = org.apache.mahout.cf.taste.impl.similarity | |
| similarity = MahoutSimilarity.TanimotoCoefficientSimilarity.new(model) |
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
| MahoutFile = org.apache.mahout.cf.taste.impl.model.file | |
| model = MahoutFile.FileDataModel.new(java.io.File.new("data.csv")) | |
| MahoutSimilarity = org.apache.mahout.cf.taste.impl.similarity | |
| # similarity = MahoutSimilarity.TanimotoCoefficientSimilarity.new(model) | |
| similarity = MahoutSimilarity.LogLikelihoodSimilarity.new(model) | |
| MahoutNeighborhood = org.apache.mahout.cf.taste.impl.neighborhood | |
| neighborhood = MahoutNeighborhood.NearestNUserNeighborhood.new(2, similarity, model) |