Skip to content

Instantly share code, notes, and snippets.

View bluetechy's full-sized avatar

bluetechy

  • Unicity International
  • Orem, UT
View GitHub Profile
@bluetechy
bluetechy / nginxproxy.md
Created April 6, 2019 05:45 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

FROM centos:7
MAINTAINER Naoaki Obiki
RUN yum update -y
RUN yum group install -y 'Development Tools'
RUN yum install -y libxml2-devel wget
RUN wget "http://jp2.php.net/get/php-7.0.9.tar.gz/from/this/mirror" -P /usr/local/src/
RUN mv /usr/local/src/mirror /usr/local/src/php-7.0.9.tar.gz
RUN wget "http://pecl.php.net/get/pthreads-3.1.6.tgz" -P /usr/local/src/

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 / 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