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
| #include <iostream> | |
| using namespace std; | |
| #define T Tree<Key, Value> | |
| #define KEY_VALUE template <class Key, class Value> | |
| KEY_VALUE | |
| class Tree { | |
| public: | |
| Tree *parent; |
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
| typedef unsigned int uint; | |
| #define Item List<Key, Value> | |
| #define KEY_VALUE template <class Key, class Value> | |
| #define FLL(a) for (Item *tmp = (a); tmp != NULL; tmp = tmp->next) | |
| KEY_VALUE | |
| struct List { | |
| Key k; | |
| Value value; | |
| Item *next; |
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
| /* | |
| * @author: basicxman | |
| * @description: http://dwite.ca/questions/cs4hs_root_of_a_string.html | |
| */ | |
| #include <iostream> | |
| using namespace std; | |
| bool TestRoot(string root, string s) { | |
| int n = s.length(); |
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
| #include "Graph.h" | |
| #define MAXINT 1000 | |
| int printPath(int start, int end, vector<int> &parents, vector<int> &distance) { | |
| cout << end << " (" << distance[end] << "): "; | |
| int a = start; | |
| int b = 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
| #include "Graph.h" | |
| #define MAXINT 1000 | |
| int findTotalWeight(int start, int end, vector<int> &parents, vector<int> &distance) { | |
| int a = start; | |
| int b = end; | |
| int totalWeight = 0; | |
| while (a != b) { |
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
| #include "Graph.h" | |
| #include <queue> | |
| #define unvisited 1 | |
| #define visited 2 | |
| #define processed 3 | |
| #define fill(a, b) fill_n((a).begin(), n, (b)) | |
| typedef vector<int> list; |
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
| void reverseList(list **l) { | |
| if ((*l)->next == NULL) return; | |
| // Hold the current list pointer for use in the actual swap, then assign the | |
| // list pointer to the next element to place us at the correct head. | |
| list *cur = *l; | |
| *l = (*l)->next; | |
| // Recurse with the new list pointer. This allows us to traverse to the | |
| // farthest element while maintaining O(n) time. |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset=utf-8 /> | |
| <title>Test</title> |
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
| 1 ~$ irb | |
| ruby-1.9.2-p136 :001 > require 'net/http' | |
| => true | |
| ruby-1.9.2-p136 :002 > require 'uri' | |
| => false | |
| ruby-1.9.2-p136 :003 > res = Net::HTTP.get_print URI.parse('http://www.wordreference.com/enfr/test') | |
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | |
| <html > | |
| <head> |
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
| # ApplicationController | |
| def render_sidebar_widget(path, item = nil) | |
| locals = {} | |
| locals = self.send(item) unless item.nil? | |
| render_to_string(:partial => path, :locals => locals).html_safe | |
| end | |
| helper_method :render_sidebar_widget | |
| def reading_list | |
| set(:reading_items, ReadingItem.updated_desc.all) |