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
<html> | |
<script type="text/javascript" | |
src="http://code.jquery.com/jquery-latest.pack.js"> | |
</script> | |
<script> | |
$(document).ready(function() { | |
function debug(str) { | |
$("#debug").append(str + "<br/>"); | |
}; |
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 'rubygems' | |
require 'em-websocket' | |
host = "0.0.0.0" | |
port = 8080 | |
clients = {} | |
EventMachine::WebSocket.start(:host => host, :port => port) do |socket| | |
puts "new connection" |
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
<html> | |
<script type="text/javascript" | |
src="http://code.jquery.com/jquery-latest.pack.js"> | |
</script> | |
<script> | |
$(document).ready(function() { | |
function debug(str) { | |
$("#debug").append(str + "<br/>"); | |
}; |
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
def qsort_partition(array, left, right, pivotindex) | |
pivotval = array[pivotindex] | |
storeindex = left | |
array[pivotindex], array[right] = array[right], array[pivotindex] | |
left.upto(right-1) do |i| | |
if array[i] < pivotval | |
array[i], array[storeindex] = array[storeindex], array[i] | |
storeindex += 1 | |
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 <stdio.h> | |
#include <stdlib.h> | |
#define TESTARRAYSIZE 20 | |
#define TESTVALMAX 100 | |
void swap(int array[], int x, int y) { | |
int tmp = array[x]; | |
array[x] = array[y]; | |
array[y] = tmp; |
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 def find_words_after array, word | |
2 list = [] | |
3 | |
4 array.each_with_index do |w, k| | |
5 if word == w | |
6 if list.index(array[k+1]).nil? | |
7 puts list | |
8 list << {array[k+1] => 0} | |
9 end | |
10 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
1 def find_words_after array, word | |
2 list = [] | |
3 | |
4 array.each_with_index do |w, k| | |
5 if word == w | |
6 if list.index(array[k+1]).nil? | |
7 puts list | |
8 list << {array[k+1] => 0} | |
9 end | |
10 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
text = File.read('text') | |
word_array = text.split | |
puts text | |
word_hash = {} | |
word_array.each { |word| word_hash[word] = [] } | |
word_hash.each do |wh_word, wv| | |
word_array.each do |p| | |
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
def build_freq_table text | |
word_array = text.split | |
word_hash = {} | |
word_array.each { |word| word_hash[word] = [] } | |
word_hash.each do |wh_word, wh_value| | |
list = {} | |
word_array.each_with_index do |wa_word, index| | |
list[word_array[index+1]] += 1 if wh_word == wa_word and not list[word_array[index+1]].nil? | |
list[word_array[index+1]] = 1 if wh_word == wa_word and list[word_array[index+1]].nil? |
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 <stdio.h> | |
#include <stdlib.h> | |
struct stack { | |
int val; | |
struct stack* next; | |
}; | |
struct stack* push(struct stack* s, int val) { | |
struct stack *new = malloc(sizeof(*new)); |