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 http-equiv="content-type" content="text/html; charset=utf-8" /> | |
<title></title> | |
<style type="text/css" media="all"> | |
</style> |
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
import bluetooth | |
print "Start discovering...." | |
nearby_devices = bluetooth.discover_devices() | |
print "Found devices:" | |
for bdaddr in nearby_devices: | |
print bluetooth.lookup_name( bdaddr ), "with address:", bdaddr |
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 "foo.h" | |
void | |
Foo::hello(){ | |
std::cout << "Hello world" << std::endl; | |
} | |
int | |
Foo::add(int a, int b){ | |
return 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 <iostream> | |
#include <iomanip> | |
#include "binary_search_tree.h" | |
bool | |
BinarySearchTree::lookup(node* n, int d) | |
{ | |
if(!n){ | |
return false; | |
} |
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> | |
#include <iomanip> | |
#include "binary_search_tree.h" | |
bool | |
BinarySearchTree::lookup(node* n, int d) | |
{ | |
while(n){ | |
if(d == n->data){ | |
return true; |
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 "binary_tree.h" | |
#include <iostream> // std::cout | |
#include <iomanip> // std::setw | |
#include <string> // std::string | |
#include <sstream> // std::istringstream | |
bool | |
BinaryTree::ReadNext(std::ifstream& fin, int* data, bool* isNumber) | |
{ | |
if(!fin.is_open() || !fin.good()){ |
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> // std::cout | |
#include <iomanip> // std::setw() | |
#include <vector> // std::vector | |
std::vector<int> getDescendants(std::vector<std::vector<int>> tree, int node){ | |
std::vector<int> descendants; | |
descendants.insert(descendants.end(), tree[node].begin(), tree[node].end()); | |
for(int i = 0 ; i < descendants.size() ; i++){ | |
if( descendants[i] < tree.size() && !tree[descendants[i]].empty() ){ | |
//append |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
#!/usr/bin/python | |
import re | |
import sys | |
def removeComments(text): | |
""" remove c-style comments. | |
text: blob of text with comments (can include newlines) | |
returns: text with comments removed | |
""" | |
pattern = r""" |
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
#!/usr/bin/python | |
class DictDiffer(object): | |
""" | |
Calculate the difference between two dictionaries as: | |
(1) items intersected | |
(2) items added | |
(3) items removed | |
(4) keys same in both but changed values | |
(5) keys same in both and unchanged values | |
""" |
OlderNewer