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 visual_board(N, game_state, only_row=False): | |
| '''Format a board game per game_state. If only_row is True, the output will be only the specified row''' | |
| board = [[] for i in range(N)] | |
| empty = '-|' | |
| for column, row in enumerate(game_state): | |
| board[row] = str(row) + ' |' + empty * column + 'Q|' + (empty * (N - column))[:-1] + '|' | |
| board[row] = board[row][:-2] + '\n' | |
| if not isinstance(only_row, bool) and only_row == row: | |
| return board[row] | |
| return ' ' + ' '.join(str(i) for i in range(n)) + '\n' + ''.join(board) |
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
| ############################################################################# | |
| ######### class Matrix with display() function for image visualization | |
| ############################################################################# | |
| class Matrix: | |
| """ | |
| Represents a rectangular matrix with n rows and m columns. | |
| """ | |
| def __init__(self, n, m, val=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
| section .text | |
| global _start | |
| _start: | |
| mov eax, 2 ; SYS_FORK Op Code | |
| int 0x80 | |
| cmp eax, 0 ;If the return value is 0, we are in the child process | |
| jz child | |
| parent: | |
| mov edx, len ;Move msg length to edx |
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
| #!/bin/bash | |
| # --- HeartHeal - Fix your broken heart (and SSL!) --- # | |
| function update { | |
| echo 'Your OpenSSL is unsafe!' | |
| echo 'Running sudo apt-get update...' | |
| sudo apt-get update | |
| echo 'DONE.' | |
| echo 'Running sudo apt-get dist-upgrade...' | |
| sudo apt-get dist-upgrade | |
| echo 'DONE.' |
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 as urllib | |
| def get_image(ip): | |
| # The header represents the beginning of the image inside the stream | |
| HEADER_MAGIC = "\xff\xd8" | |
| # Get the stream and the initial data buffer | |
| bytes = '' | |
| stream = urllib.urlopen(ip) | |
| # Start reading values | |
| while True: | |
| # Read the first 70 bytes to find the content length and the header magic |
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
| spoiler:hover { | |
| text-shadow: none; | |
| color: #000; | |
| filter: none; | |
| } | |
| spoiler { | |
| text-shadow: 0 0 8px #000; | |
| color: rgba(255,255,255,0); | |
| filter: DXImageTransform.Microsoft.Blur(pixelradius=2); |
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 json | |
| import urllib2 as urllib | |
| import sys | |
| def get_urls(limit=5): | |
| '''Get the url and titles from /r/EarthPorn''' | |
| # This is the api endpoint for hot submissions in /r/EarthPorn | |
| api_url = 'http://www.reddit.com/r/EarthPorn/hot.json?limit=' + str(limit) | |
| # Let's store this in urlopen | |
| json_url = urllib.urlopen(api_url) |
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 as urllib | |
| import re | |
| import random | |
| import plistlib | |
| catgories = { | |
| 'Age' : 'c[54]', \ | |
| 'Art' : 'c[44]', \ | |
| 'Beauty' : 'c[40]', \ | |
| 'Emotion' : 'c[121]', \ |
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
| from scapy.all import * | |
| import time | |
| from SimpleHTTPServer import * | |
| import thread | |
| from os import system | |
| import urllib2 | |
| routerIP = '10.0.2.2' | |
| victimsIP = ['10.0.2.' + i for i in xrange(0, 255)] | |
| myIP = '192.168.15.134' |
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 <gtk/gtk.h> | |
| void GtkTextviewAppend(GtkWidget *textview, gchar *text) | |
| { | |
| //Append a string to a textview | |
| GtkTextBuffer *tbuffer; | |
| GtkTextIter ei; | |
| tbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)); | |
| gtk_text_buffer_get_end_iter(tbuffer, &ei); |