This file contains 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 SStack as Stack exposing (..) | |
import Html exposing (..) | |
reverseString : String -> String | |
reverseString str = | |
Stack.reverse str | |
main : Html.Html | |
main = |
This file contains 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 Graphics.Element (Element, flow, down) | |
import List (map) | |
import Text (asText) | |
main : Element | |
main = | |
let fizzBuzz n = case (n % 3, n % 5) of | |
(0, 0) -> "FizzBuzz" | |
(0, _) -> "Fizz" | |
(_, 0) -> "Buzz" |
This file contains 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) C++: - Defining a dictionary [key type=string, value type=int] | |
// - No easy way to initialize. | |
// | |
map<string, int> dict; | |
// | |
// (1`) C++11: Defining and initializing a dictionary [key type=string, value type=int] | |
// | |
map<string, int> dict | |
{ |
This file contains 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) C#: Defining an initializing a dictionary [key type=string, value type=int] | |
// | |
Dictionary<string, int> dict = new Dictionary<string, int>() | |
{ | |
{"Eve", 101}, | |
{"George", 150}, | |
{"Emma", 200} | |
}; | |
// |
This file contains 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
from collections import namedtuple | |
# A reasonable large number to represent infinity. | |
INF = (1 << 31) | |
UNIT_LENGTH = 6 | |
# Struct for edges. | |
Edge = namedtuple('Edge', ['src', 'dest']) | |
def calculate_shortest_distances(node_num, edges, src): |
This file contains 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
Scapy: send, sniff and dissect and forge network packets. Usable interactively or as a library | |
pypcap, Pcapy and pylibpcap: several different Python bindings for libpcap | |
libdnet: low-level networking routines, including interface lookup and Ethernet frame transmission | |
dpkt: fast, simple packet creation/parsing, with definitions for the basic TCP/IP protocols | |
Impacket: craft and decode network packets. Includes support for higher-level protocols such as NMB and SMB | |
pynids: libnids wrapper offering sniffing, IP defragmentation, TCP stream reassembly and port scan detection | |
Dirtbags py-pcap: read pcap files without libpcap | |
flowgrep: grep through packet payloads using regular expressions | |
Knock Subdomain Scan, enumerate subdomains on a target domain through a wordlist | |
Mallory, extensible TCP/UDP man-in-the-middle proxy, supports modifying non-standard protocols on the fly |
This file contains 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
(* | |
enterprise-tic-tac-toe-2.fsx | |
Follow up to the example of implementing "enterprise" tic-tac-toe in a functional way. | |
* Added true capability based security. | |
Related blog post: http://fsharpforfunandprofit.com/posts/enterprise-tic-tac-toe-2/ | |
*) |
This file contains 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
var serialAsyncMap = function () { | |
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(collection, fn) { | |
var result, _iterator, _isArray, _i, _ref2, item; | |
return regeneratorRuntime.wrap(function _callee$(_context) { | |
while (1) { | |
switch (_context.prev = _context.next) { | |
case 0: | |
result = []; | |
_iterator = collection, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator](); |
This file contains 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 requests | |
import lxml | |
from lxml import html | |
r = requests.get('http://gun.io') | |
tree = lxml.html.fromstring(r.content) | |
elements = tree.get_element_by_id('frontsubtext') | |
for el in elements: | |
print el.text_content() |
This file contains 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/env python | |
"""A tiny script that polls your location on Google Latitude, and updates | |
the color of a Blink1 LED. http://shop.thingm.com/blink1/ | |
Red = At work | |
Blue = At home | |
Green = On my way | |
Should work on Windows, OS-X and Linux. Requires Python 2.7 or later. |