Skip to content

Instantly share code, notes, and snippets.

View kobus1998's full-sized avatar
😳
-10x programmer

Kobus kobus1998

😳
-10x programmer
View GitHub Profile
@paulirish
paulirish / gist:292907
Created February 2, 2010 18:50
ascii art that's perfect for code comments
/* __
/ _)
.-^^^-/ /
__/ /
<__.|_|-|_|
*/
/*_/|
=0-0=
@kobus1998
kobus1998 / something.php
Created July 18, 2018 13:50
PHP Validate mail body
<?php
/**
* Make sure lines are right length in mail body
* @param string mail body
* @param int max line length (default 68)
* @param bool only return bool instead of modified body (default false)
* @return string|bool validated body
*/
function validateMailBody($sBody, $iMaxLen = 68, $bReturnBool = false)
@gustavohenrique
gustavohenrique / soap-curl-shell
Created June 11, 2013 19:24
SOAP request using curl
# request.xml
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wst="http://sensedia.com/repository/wstoolkit">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-1">
<wsse:Username>system</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">manager</wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">DWk64SMfJ6RxHAKgPRGtPA==</wsse:Nonce>
<wsu:Created>2013-04-17T18:36:54.013Z</wsu:Created>
</wsse:UsernameToken>
@quark-zju
quark-zju / lodash.hpp
Last active February 5, 2020 02:14
Little C++ header inspired by Ruby and Lo-dash
// compile with -std=c++1y
#include <algorithm>
#include <functional>
#include <iterator>
#include <vector>
namespace LoDash {
using std::begin;
@smalot
smalot / PdfParser.php
Last active February 13, 2022 09:59
Use this static class to extract Text from Pdf files. It supports compressed and uncompressed Pdf (version 1.1 to 1.7) : tested It supports octal encoded (eg : \050) content, but not hexadecimal (eg : <005E>). In some cases, it works better than "pdftotext" binary tool.
<?php
/**
* @file
* Class PdfParser
*
* @author : Sebastien MALOT <sebastien@malot.fr>
* @date : 2013-08-08
*
* References :
@witooh
witooh / graphicsmagick.sh
Created February 1, 2015 17:42
Install Graphicsmagick
sudo apt-get install python-software-properties
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:rwky/graphicsmagick
sudo apt-get update
sudo apt-get install graphicsmagick
@srsbiz
srsbiz / gist:8373451ed3450c0548c3
Last active December 24, 2022 15:01
php AES-128-CBC mcrypt & openssl
<?php
function encrypt_mcrypt($msg, $key, $iv = null) {
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
if (!$iv) {
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
}
$pad = $iv_size - (strlen($msg) % $iv_size);
$msg .= str_repeat(chr($pad), $pad);
$encryptedMessage = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $msg, MCRYPT_MODE_CBC, $iv);
return base64_encode($iv . $encryptedMessage);
@JonDum
JonDum / dd-afk.ahk
Created November 11, 2011 04:14
Dungeon Defenders AFK script
;
; Usage: Save to a .ahk file
;
; Control+Shift+G to activate hitting G once a second
; Control+Alt+G to deactivate
; Control+C to close the script completely
;
active=0
@tsaarni
tsaarni / openssl-notes.txt
Created October 22, 2016 08:50
Generate self-signed certs with different key types
*** RSA
# Generate self-signed certificate with RSA 4096 key-pair
openssl req -x509 -nodes -days 3650 -newkey rsa:4096 -keyout rsakey.pem -out rsacert.pem
# print private and public key
openssl rsa -in rsakey.pem -text -noout
# print certificate
openssl x509 -in rsacert.pem -text -noout
@samarpanda
samarpanda / gist:4125105
Last active December 1, 2023 08:20
Test your php code execution time and Memory usage
<?php
// from http://php.net/manual/en/function.filesize.php
function formatBytes($bytes, $precision = 2) {
$units = array('B', 'KB', 'MB', 'GB', 'TB');
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
$pow = min($pow, count($units) - 1);