Skip to content

Instantly share code, notes, and snippets.

@danieltroger
danieltroger / gist:9b62c82394c940c85e1a
Created September 27, 2014 11:14
Generate a pdf with all jpg's in a directory
<?php
/* http://www.fpdf.org/ minified */
define('FPDF_VERSION','1.7');class FPDF{var $page;var $n;var $offsets;var $buffer;var $pages;var $state;var $compress;var $k;var $DefOrientation;var $CurOrientation;var $StdPageSizes;var $DefPageSize;var $CurPageSize;var $PageSizes;var $wPt,$hPt;var $w,$h;var $lMargin;var $tMargin;var $rMargin;var $bMargin;var $cMargin;var $x,$y;var $lasth;var $LineWidth;var $fontpath;var $CoreFonts;var $fonts;var $FontFiles;var $diffs;var $FontFamily;var $FontStyle;var $underline;var $CurrentFont;var $FontSizePt;var $FontSize;var $DrawColor;var $FillColor;var $TextColor;var $ColorFlag;var $ws;var $images;var $PageLinks;var $links;var $AutoPageBreak;var $PageBreakTrigger;var $InHeader;var $InFooter;var $ZoomMode;var $LayoutMode;var $title;var $subject;var $author;var $keywords;var $creator;var $AliasNbPages;var $PDFVersion;function FPDF($orientation='P',$unit='mm',$size='A4'){$this->_dochecks();$this->page=0;$this->n=2;$this->buffer='';$this->pages=array();$this->PageSizes=array();$th
@danieltroger
danieltroger / gist:b89ecca95f2e058e6120
Last active August 29, 2015 14:06
Didn't find a fpdf CDN, so i'm using github...
<?php
define('FPDF_VERSION','1.7');class FPDF{var $page;var $n;var $offsets;var $buffer;var $pages;var $state;var $compress;var $k;var $DefOrientation;var $CurOrientation;var $StdPageSizes;var $DefPageSize;var $CurPageSize;var $PageSizes;var $wPt,$hPt;var $w,$h;var $lMargin;var $tMargin;var $rMargin;var $bMargin;var $cMargin;var $x,$y;var $lasth;var $LineWidth;var $fontpath;var $CoreFonts;var $fonts;var $FontFiles;var $diffs;var $FontFamily;var $FontStyle;var $underline;var $CurrentFont;var $FontSizePt;var $FontSize;var $DrawColor;var $FillColor;var $TextColor;var $ColorFlag;var $ws;var $images;var $PageLinks;var $links;var $AutoPageBreak;var $PageBreakTrigger;var $InHeader;var $InFooter;var $ZoomMode;var $LayoutMode;var $title;var $subject;var $author;var $keywords;var $creator;var $AliasNbPages;var $PDFVersion;function FPDF($orientation='P',$unit='mm',$size='A4'){$this->_dochecks();$this->page=0;$this->n=2;$this->buffer='';$this->pages=array();$this->PageSizes=array();$this->state=0;$this->fonts=array();$th
@danieltroger
danieltroger / build.sh
Last active August 29, 2015 14:07
Minify all phpjs functions into one
#!/bin/bash
echo "Getting/updating phpjs from github..."
if [ ! -d phpjs ]
then
git clone https://github.com/kvz/phpjs
else
cd phpjs
git pull
cd ..
fi
@danieltroger
danieltroger / php.js
Created October 10, 2014 18:24
PHPJS minified
This file has been truncated, but you can view the full file.
function preg_grep(pattern,input,flags){var p="";var retObj={};var invert=(flags===1||flags==="PREG_GREP_INVERT");if(typeof pattern==="string"){pattern=eval(pattern)}if(invert){for(p in input){if((input[p]+"").search(pattern)===-1){retObj[p]=input[p]}}}else{for(p in input){if((input[p]+"").search(pattern)!==-1){retObj[p]=input[p]}}}return retObj};function var_export(g,n){var j="",d="",l,e=0,k=[],h=0,c=[],m=arguments[2]||2,f="",b="",a=function(o){var i=(/\W*function\s+([\w\$]+)\s*\(/).exec(o);if(!i){return"(Anonymous)"}return i[1]};_makeIndent=function(i){return(new Array(i+1)).join(" ")};__getType=function(t){var r=0,p,q,o,s=typeof t;if(s==="object"&&(t&&t.constructor)&&a(t.constructor)==="PHPJS_Resource"){return"resource"}if(s==="function"){return"function"}if(s==="object"&&!t){return"null"}if(s==="object"){if(!t.constructor){return"object"}o=t.constructor.toString();p=o.match(/(\w+)\(/);if(p){o=p[1].toLowerCase()}q=["boolean","number","string","array"];for(r=0;r<q.length;r++){if(o===q[r]){s=q[r];break}}}ret
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<script>function json_decode(str_json){var json=this.window.JSON;if(typeof json==="object"&&typeof json.parse==="function"){try{return json.parse(str_json)}catch(err){if(!(err instanceof SyntaxError)){throw new Error("Unexpected error type in json_decode()")}this.php_js=this.php_js||{};this.php_js.last_error_json=4;return null}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;var j;var text=str_json;cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}if((/^[\],:{}\s]*$/).test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return j}this.php_js=this.php_js||{};this.php_js.last_error_json=4;return null};function json_encode(g){var e,b=this.win
@danieltroger
danieltroger / imagr.php
Created November 23, 2014 16:01
Get and extract imagr from github. Dirty but works. Uses 2MB RAM max.
<?php
$od = $_REQUEST['dir'];
$ul = $_REQUEST['ul'];
if($ul == "true"){$ul = true;}else{$ul = false;}
if(is_dir($od) || file_exists($od) || strlen($od) < 3 || strpos($od,"..") !== false){die("u made shit, dir is undefined");}
$server = "codeload.github.com";
$sock = fsockopen("ssl://" . $server,443);
fputs($sock,"GET /danieltroger/imagr/zip/master HTTP/1.1\nHost: {$server}\r\n\r\n");
$h = fopen("tmp.zip","w");
$p = false;
@danieltroger
danieltroger / fritz-down.php
Created November 23, 2014 18:22
Gets the current downspeeed bandwith usage from a fritzbox
<?php
// worst unreadable shit but works
// dial #96*7* on your fritz box connected phone to get this working.
$h = fsockopen("fritz.box",23);
sleep(1);
fputs($h,"secretpass" . PHP_EOL);
stream_set_blocking($h,0);
$cmd = "echo \$((\$(ctlmgr_ctl r nqos settings/stat/ds_current_bps|sed 's/,.*//')*8 ))" . PHP_EOL;
$s = 0;
while(1)
@danieltroger
danieltroger / sort.php
Last active August 29, 2015 14:12 — forked from anonymous/sort.php
Sort video files.
#!/usr/bin/php
<?php
echo "\r \r"; // if you have executed this with the php CLI (php filename), we remove the shebang
declare(ticks = 1);
/*
The MIT License (MIT)
Copyright (c) 2014-2015 Daniel Troger
Permission is hereby granted, free of charge, to any person obtaining a copy of
@danieltroger
danieltroger / size.md
Last active August 29, 2015 14:16
Formatsize

#On the fly php <(curl -s https://gist.githubusercontent.com/danieltroger/b4f04eded3cd4eda44f9/raw/a8f8a49f3ed742aaab8d349fa0ec5ab64a767c96/size.php) <byte value>

#Download:

./size.sh ```
@danieltroger
danieltroger / vmux.html
Created March 23, 2015 14:09
Video multiplexer
<!DOCTYPE html>
<html>
<body>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<video autoplay style="display: none;">
<source src="//download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_h264.mov" type="video/mp4">
<source src="//download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_stereo.ogg" type="video/ogg">
<!-- <source src="big_buck_bunny_480p_h264.mov" type="video/mp4">