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
"""Mimic Java's PBEWithMD5AndDES algorithm to produce a DES key | |
Closely based in https://stackoverflow.com/a/44509919 | |
""" | |
import base64 | |
import re | |
from Crypto.Cipher import DES | |
from Crypto.Hash import MD5 |
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 javax.servlet.ServletException; | |
import javax.servlet.annotation.WebServlet; | |
import javax.servlet.http.HttpServlet; | |
import javax.servlet.http.HttpServletRequest; | |
import javax.servlet.http.HttpServletResponse; | |
import java.io.IOException; | |
import java.io.PrintWriter; | |
@WebServlet("/welcome") | |
public class ExemploServlet extends HttpServlet { |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" | |
version="3.1"> | |
<servlet> | |
<servlet-name>watermelon</servlet-name> | |
<servlet-class>myservlets.watermelon</servlet-class> | |
</servlet> |
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
package fanese.web.model; | |
import java.sql.Connection; | |
import java.sql.DriverManager; | |
import java.sql.PreparedStatement; | |
import java.sql.SQLException; | |
public class Database { | |
private static final String DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; |
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/env python3.4 | |
def hashtags(text): | |
return set(re.findall(r"(?:^|\W+)#+(\w+(?!#+.*))\b", text)) |
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
public interface InterceptHandler { | |
InterceptEnum beforePublish(ProtocolEvent evt, InterceptContinue continuation); | |
InterceptEnum beforeSubscribe(ProtocolEvent evt, InterceptContinue continuation); | |
InterceptEnum beforeConnect(ProtocolEvent evt, InterceptContinue continuation); | |
void onConnect(ConnectMessage msg); | |
void onPublish(PublishMessage msg); | |
void onSubscribe(SubscribeMessage msg); | |
void onUnsubscribe(SubscribeMessage msg); | |
} |
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
public class MyInterceptor extends AbstractInterceptor { | |
private static PrintStream log; | |
static { | |
try { | |
final File f = new File("/tmp/moquette-subscribe-events.log"); | |
log = new PrintStream(f); | |
} catch (FileNotFoundException e) { | |
e.printStackTrace(); | |
} | |
} |
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 sys, os, re | |
info = {"folder": sys.argv[1], "extensions": sys.argv[2].split(","), "statements": dict.fromkeys(["if", "for", "while", "do", "switch", "case"], 0), "lines": 0} | |
for dirpath, dirnames, filenames in os.walk(info["folder"]): | |
for filelines in [open(os.path.join(dirpath, fname)).readlines() for fname in filenames if fname.split(".")[-1] in info["extensions"]]: | |
for line in filelines: | |
info["lines"] += 1 | |
found = re.search(r"^\s*(%s)\b" % "|".join(info["statements"].keys()), line) | |
if found != None: info["statements"][found.group(1)] += 1 | |
print "O seu codigo possui:\n %d linhas\n" % info["lines"] + "\n".join(" %s: %d" % (k, v) for k, v in info["statements"].iteritems()) |
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 .data | |
msg db 'Hello World', 0xa ; variável db | |
len equ $ - msg ; tamanho variável | |
global _start | |
_start: | |
mov edx, len | |
mov ecx, msg | |
mov ebx, 1 ; File Descriptor (stdout) |
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 unittest | |
def word_wrapper(frase, coluna): | |
linha = 0 | |
palavras = [] | |
frases = [] | |
for palavra in frase.split(): | |
tamanho_palavra = len(palavra) + 1 |