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 urllib2 | |
| import random | |
| import difflib | |
| import datetime | |
| def fetch(url): | |
| """Fetches requested url, returns lines in list""" | |
| response = urllib2.urlopen(url) | |
| lines = response.readlines() | |
| return lines |
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 sortCommands(histFile, limit=10) | |
| file = open(histFile, 'r') | |
| lines = file.readlines | |
| file.close | |
| freqs = Hash.new(0) | |
| lines.each do |line| | |
| freqs[line] += 1 | |
| end | |
| a = freqs.sort_by {|k, v| -v}[0..limit] | |
| i = 0 |
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 find_max(data): | |
| """Return the maximum element from a nonempty Python list.""" | |
| biggest = data[0] | |
| for val in data: | |
| if val > biggest: | |
| biggest = val | |
| return biggest |
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 Data.Char (digitToInt) | |
| numberToBaseString :: Int -> Int -> String | |
| numberToBaseString n base | |
| | n < base = show n | |
| | otherwise = numberToBaseString ((n - (n `mod` base)) `div` base) base ++ show (n `mod` base) | |
| baseStringToValue :: String -> Int -> Int | |
| baseStringToValue n base | |
| | n == [] = 0 |
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
| puts' ______________________________ ' | |
| puts'< What\'s wrong with this food? >' | |
| puts' ------------------------------ ' | |
| puts' \ ^__^' | |
| puts' \ (oo)\_______' | |
| puts' (__)\ )\/\'' | |
| puts' ||----w |' | |
| puts' || ||' |
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 <vector> | |
| #include <map> | |
| #include <string> | |
| #include <cmath> | |
| #include <regex> | |
| #include <sstream> | |
| using namespace std; |
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; | |
| class Stack_overflow {}; | |
| class Stack_underflow {}; | |
| class Stack { | |
| public: | |
| Stack(int sz) : sz{sz}, top{-1}, elem {new int[sz]} {}; |
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
| server.register(require('hapi-auth-jwt2'), function(err) { | |
| if (err) { | |
| throw err; | |
| } | |
| server.auth.strategy('token', 'jwt', false, { | |
| key: constants.application.secretKey, | |
| validateFunc: function(decoded, request, callback) { | |
| if (!decoded || !decoded.verified) { | |
| return callback(null, 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
| // requires cypher-rest | |
| // npm i cypher-rest | |
| // gist for http://stackoverflow.com/questions/35191765/how-can-we-copy-labels-from-one-node-to-another-in-one-cypher | |
| 'use strict'; | |
| const util = require('util'); | |
| const c = require('cypher-rest'); | |
| const neoUrl = 'http://127.0.0.1:7474/db/data/transaction/commit'; |
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 strict'; | |
| var _fstore = []; | |
| function factorial (n) { | |
| if (n == 0 || n == 1) { | |
| return 1; | |
| } | |
| if (_fstore[n] > 0) { | |
| return _fstore[n]; | |
| } |
OlderNewer