Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/php
<?php
/**
* filename: ghdb
*
* usage: ghdb [info|list|update]
*
* Crude example of PHP HTML DOM and SQLite combination to archive
* data from a website. Posted as reference.
*
package main
import (
"net/http"
"fmt"
"flag"
)
func main() {
@NanoDano
NanoDano / Python Requests Log In
Last active October 1, 2020 01:06
Python Requests Log In to Drupal
import requests
postData = {
'name': 'username',
'pass': 'secret!',
'form_id': 'user_login',
'op': 'Log in'
}
loginUrl = 'http://www.some-drupal-site.com/user'
@NanoDano
NanoDano / analyze_subreddit_titles.py
Last active May 31, 2022 01:02
Word Frequency of a Subreddit's Post Titles
"""
Analyze word frequency in subreddit post titles
Outputs the number of times a word is seen and orders them
by the most used words.
Quick and dirty script that is not optimized
nanodano@devdungeon.com
www.devdungeon.com
"""
min_word_length = 5 # Ignore words shorter than this length
@NanoDano
NanoDano / extract_pngs.py
Created July 31, 2016 18:23
Extract PNGs from a file using Python
# extract_pngs.py
# Extract PNGs from a file and put them in a pngs/ directory
import sys
with open(sys.argv[1], "rb") as binary_file:
binary_file.seek(0, 2) # Seek the end
num_bytes = binary_file.tell() # Get the file size
count = 0
for i in range(num_bytes):
binary_file.seek(i)
@NanoDano
NanoDano / create_stego_zip_jpg.py
Created July 31, 2016 18:24
Create a stego image/zip archive with Python
# create_stego_zip_jpg.py - Hide a zip file inside a JPEG
import sys
# Start with a jpeg file
jpg_file = open(sys.argv[1], 'rb') # Path to JPEG
jpg_data = jpg_file.read()
jpg_file.close()
# And the zip file to embed in the jpeg
@NanoDano
NanoDano / find_ascii_in_binary.py
Created July 31, 2016 18:24
Find ASCII characters in a binary file with Python
# find_ascii_in_binary.py - Identify ASCII characters in binary files
import sys
from functools import partial
chunk_size = 1
with open(sys.argv[1], 'rb') as in_file:
for data in iter(partial(in_file.read, chunk_size), b''):
x = int.from_bytes(data, byteorder='big')
if (x > 64 and x < 91) or (x > 96 and x < 123) :
@NanoDano
NanoDano / is_jpeg.py
Created July 31, 2016 18:24
See if a file is a JPG with Python
#is_jpeg.py - Does the file have a JPEG binary signature?
import sys
import binascii
jpeg_signatures = [
binascii.unhexlify(b'FFD8FFD8'),
binascii.unhexlify(b'FFD8FFE0'),
binascii.unhexlify(b'FFD8FFE1')
]
@NanoDano
NanoDano / selenium_ruby.rb
Created July 31, 2016 18:25
Ruby Selenium Example
require 'selenium-webdriver'
browser = Selenium::WebDriver.for :firefox
# Load a page
begin
browser.navigate.to 'http://www.devdungeon.com'
rescue
puts 'Error loading page.'
end