Skip to content

Instantly share code, notes, and snippets.

View KaiserWerk's full-sized avatar

Robin K. KaiserWerk

  • Germany
  • 06:42 (UTC +02:00)
View GitHub Profile
@KaiserWerk
KaiserWerk / scrape.php
Last active January 11, 2021 12:46 — forked from jongacnik/scrape.php
Tumblr image scrape
<?php
$offset = 0;
$count = 50;
$domain = $argv[1];
$tagged = isset($argv[2]) ? $argv[2] : false;
$api = 'http://' . $domain . '.tumblr.com/api/read/json?debug=1&num=' . $count . ($tagged ? '&tagged=' . $tagged : '');
function scrape ($api, $count, $offset) {
@KaiserWerk
KaiserWerk / URLMatcher.md
Last active February 1, 2019 02:17
A vanilla PHP URL Matcher working with DocBlock Annotations
  • Create a base Controller class (usually just Controller.php)
  • Extend you Controllers (e.g. DefaultController.php or AuthenticationController.php) with the base Controller class
  • Add the @Route("/route", name="route_name") annotation to your methods' DocBlock
  • Initialize the URLMatcher
  • ???
  • Profit
@KaiserWerk
KaiserWerk / requirements_check.php
Created February 3, 2019 01:35
Simple requirements check
<?php
if (version_compare(PHP_VERSION, '7.0.0') < 0) {
die('PHP 7 is required; your version is ' . PHP_VERSION);
}
$extensions = get_loaded_extensions();
$requiredExtensions = [
'json',
@KaiserWerk
KaiserWerk / Session.php
Created February 25, 2019 10:04
Store sessions in DB (using using catfan/medoo)
<?php
class Session
{
private $db = false;
public function __construct()
{
$this->db = new \Medoo\Medoo(); // http://medoo.in
@KaiserWerk
KaiserWerk / file_list_2_file_size_order.php
Last active March 11, 2019 20:53
List files recusively ordered by file size
<?php
/**
* Source: https://www.jodyhatton.com/how-big-is-my-website-how-to-get-a-list-of-all-files-and-folders-directories-using-php/
*/
$pathLen = 0;
function prePad($level)
{
$ss = "";
@KaiserWerk
KaiserWerk / .gitignore
Created April 21, 2019 10:05
.gitignore template
/.idea/
/.git/
/vendor/
/var/*
!/var/cache
/var/cache/*
!var/cache/.gitkeep
!/var/lock
/var/lock/*
@KaiserWerk
KaiserWerk / pdf_cracker.py
Last active March 10, 2022 19:52
Python Password Crackers
# From: https://github.com/nitin42/Python-Automation/blob/master/project15.py
# Brute-Force PDF Password Breaker
# Brute-Forcing the pdf files to break the encryption using dictionary attack
import os
import PyPDF2
@KaiserWerk
KaiserWerk / FolderDialog.cs
Last active March 23, 2020 18:15
Dialogs
// Install NuGet package WindowsAPICodePack-Shell by Aybe
//
// using Microsoft.WindowsAPICodePack.Dialogs;
CommonOpenFileDialog dialog = new CommonOpenFileDialog();
dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
dialog.IsFolderPicker = true;
if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
{
Debug.WriteLine(dialog.FileName);
// just an example object
MyObj obj = // receive from somewhere
object temp = new object();
PropertyInfo[] properties = typeof(obj).GetProperties();
foreach (PropertyInfo property in properties)
{
var name = property.Name; // gets the name of the property as a string
var value = property.GetValue(temp, null); // get the value of the property
@KaiserWerk
KaiserWerk / WriteCache.php
Last active April 7, 2020 06:26
Writing a PHP cache file using PHP
<?php
// reading data from any source
$array = call_procedure_here();
$output = '<?php' . PHP_EOL . '$myarray = ' . var_export($array, true) . ';' . PHP_EOL . '?>';
file_put_contents(__DIR__ . '/cache/cache_file.php', $output);
// include in other files
include __DIR__ . '/cache/cache_file.php';
?>