Skip to content

Instantly share code, notes, and snippets.

View bluetechy's full-sized avatar

bluetechy

  • Unicity International
  • Orem, UT
View GitHub Profile

BECOM SUDO USER:

sudo -s

INSTALL WEBSTATIC REPO FOR CENTOS/RED HAT 7:

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
@bluetechy
bluetechy / mb_str_pad.php
Created October 23, 2018 11:42 — forked from nebiros/mb_str_pad.php
mb_str_pad
<?php
/**
* mb_str_pad
*
* @param string $input
* @param int $pad_length
* @param string $pad_string
* @param int $pad_type
* @return string
@bluetechy
bluetechy / laravel_encryption.py
Created August 16, 2018 06:35 — forked from nbah22/laravel_encryption.py
Laravel-compatible encryption and decryption in python
import os
import json
import hashlib
import hmac
import base64
from Crypto.Cipher import AES
from phpserialize import loads, dumps
def mcrypt_decrypt(value, iv):
@bluetechy
bluetechy / crypt.py
Created August 16, 2018 06:35 — forked from fideloper/crypt.py
Decrypt Laravel-encrypted value
import os
import base64
import json
from Crypto.Cipher import AES
from phpserialize import loads
def decrypt(payload):
data = json.loads(base64.b64decode(payload))
@bluetechy
bluetechy / Matching Rijndael-128 in C#.NET, PHP, and Python
Created August 16, 2018 06:34 — forked from jeruyyap/Matching Rijndael-128 in C#.NET, PHP, and Python
Matching Encrypt/Decrypt Methods With Rijndael-128, CBC Mode, PKCS7 Padding in C#.NET, PHP, And Python
DO NOT use these as-is for anything important!
These are only very basic examples and they are missing much of what would be needed for a real-world use case.
These are snippets for matching encrypt and decrypt (Rijndael-128 in CBC mode with PKCS7 padding) in C#.NET, PHP, and Python.
I cobbled these together from various existing examples because at the time it seemed like a lot of existing examples out there for different languages/platforms did not quite match and would require quite a bit more work before they would encrypt/decrypt identically.
Each of these take Keys and IVs that are 16 character strings encoded in base64.
@bluetechy
bluetechy / patternmatching.py
Created August 10, 2018 13:13 — forked from chadselph/patternmatching.py
Functional language style pattern matching in python with a decorator
from collections import defaultdict
class BadMatch(NameError):
"""Exception when your args don't match a pattern"""
pass
class Any(object):
"""
>>> 'wutup' == Any()
True
@bluetechy
bluetechy / test_flask.py
Created August 9, 2018 21:12 — forked from taudep/test_flask.py
Sample Flask Python server
from flask import Flask, g, request, flash, url_for, redirect, render_template, abort
from flaskext.jsonify import jsonify
from flaskext.sqlalchemy import *
from sqlalchemy import *
from pyodbc import *
import logging
DATABASE = "dsn=Foo;Trusted_Connection=Yes"
SECRET_KEY = "asdasdfasd1234sdagfa23asdfg123"
@bluetechy
bluetechy / SQL - Stored Procedure.php
Created June 20, 2018 21:48 — forked from AVDW/SQL - Stored Procedure.php
PHP - Connecting to and executing a stored procedure in an SQL server.
$serverName = "value.cloudapp.net";
$connectionInfo = array( "Database"=>"value", "UID"=>"value", "PWD"=>"value");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false )
{
echo "Could not connect.\n";
print('<pre>');
die( print_r( sqlsrv_errors(), true));
print('</pre>');
}
@bluetechy
bluetechy / gist:106c2cfff9b0fa2203a8c215efc8ab18
Created February 14, 2018 17:36 — forked from vladimirtsyupko/gist:10964772
Git force pull to overwrite local files
git fetch --all
git reset --hard origin/master
git pull origin master
public class EZMap<T> {
public static void main(String[] args) {
Map<String,Object> m = hashMap(
bob -> 5,
TheGimp -> 8,
incredibleKoolAid -> "James Taylor",
heyArnold -> new Date()
);
System.out.println(m);
}