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 / gist:dcaa5af71f4a2dc51f940469aa705621
Created November 22, 2017 07:00
Tracking Number Link Generator (UPS, FedEx, DHL)
import re
def tracking_link_html(tracking_number):
regex_handlers = [
(r'\b(1Z ?[0-9A-Z]{3} ?[0-9A-Z]{3} ?[0-9A-Z]{2} ?[0-9A-Z]{4} ?[0-9A-Z]{3} ?[0-9A-Z]|[\dT]\d\d\d ?\d\d\d\d ?\d\d\d)\b', ups_link),
(r'(\b96\d{20}\b)|(\b\d{15}\b)|(\b\d{12}\b)', fedex_link),
(r'\b((98\d\d\d\d\d?\d\d\d\d|98\d\d) ?\d\d\d\d ?\d\d\d\d( ?\d\d\d)?)\b', fedex_link),
(r'^[0-9]{12}$', fedex_link),
(r'^[0-9]{10}$', dhl_link)
@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 / BrowserLikeTabs.js
Created February 1, 2023 06:08 — forked from Rahul-RB/BrowserLikeTabs.js
Dynamically add and remove tabs in Material UI (Browser tabs feature)
/* No licenses, use as pleased.
* The code here uses React Class components (ES6 classes).
* Ken Nguyen has made a hooks version of this! Please find that here: https://codesandbox.io/s/addanddelete-tabs-mui-bo7tw
* Cheers!
*/
import React, { Component } from "react";
import {
withStyles,
AppBar,
@bluetechy
bluetechy / pbcopyfy
Created November 7, 2022 10:41 — forked from garywoodfine/pbcopyfy
Simple Script to configure pbcopy like functionality on ubuntu
#!/bin/sh
# Copyright (C) 2009-2017 Three Nine Consulting
# Always good practice to update packages. However ask user if they would like to do so
# For explanation on how this works and why check out https://garywoodfine.com/use-pbcopy-on-ubuntu/
read -p "Do you want to update your package repositories before proceeding ? " -n 1 -r
echo #adding new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
sudo apt update
sudo apt upgrade -y
@bluetechy
bluetechy / merge
Created November 21, 2020 01:09 — forked from tmiller/merge
Bash script to merge master into all branches
#!/bin/bash
# Merges the master branch into all other branches
#
# Process:
#
# - Save the name of the current branch
# - If the current branch is not master then checkout master.
# - Pull the latest changes for master from its upstream branch.
# - Loop over each local branch.
@bluetechy
bluetechy / Component.jsx
Created November 11, 2020 06:57 — forked from krambertech/Component.jsx
ReactJS: Input fire onChange when user stopped typing (or pressed Enter key)
import React, { Component } from 'react';
import TextField from 'components/base/TextField';
const WAIT_INTERVAL = 1000;
const ENTER_KEY = 13;
export default class TextSearch extends Component {
constructor(props) {
super();
@bluetechy
bluetechy / ngrx8_with_immer.ts
Created October 17, 2020 06:31 — forked from born2net/ngrx8_with_immer.ts
ngrx 8+ with immer and support for on() within reducer
import {createReducer} from '@ngrx/store';
import {on} from "@ngrx/store";
import produce, {Draft} from "immer";
export const initialUserState: IUserState = {
knownUsers: [user1, user2],
selectedUser: null,
scenes: null
};
@bluetechy
bluetechy / GitHub curl.sh
Created July 29, 2020 03:36 — forked from Integralist/GitHub curl.sh
Download a single file from a private GitHub repo. You'll need an access token as described in this GitHub Help article: https://help.github.com/articles/creating-an-access-token-for-command-line-use
curl --header 'Authorization: token INSERTACCESSTOKENHERE' \
--header 'Accept: application/vnd.github.v3.raw' \
--remote-name \
--location https://api.github.com/repos/owner/repo/contents/path
# Example...
TOKEN="INSERTACCESSTOKENHERE"
OWNER="BBC-News"
REPO="responsive-news"
@bluetechy
bluetechy / gist:4c214d415bcef8c02bc4a8483d3fc4c9
Created July 28, 2020 08:54 — forked from madrobby/gist:9476733
Download a single file from a private GitHub repo. You'll need an access token as described in this GitHub Help article: https://help.github.com/articles/creating-an-access-token-for-command-line-use
curl -H 'Authorization: token INSERTACCESSTOKENHERE' -H 'Accept: application/vnd.github.v3.raw' -O -L https://api.github.com/repos/owner/repo/contents/path
<?php
// generate private/public key as follows:
// > openssl genrsa -out private.pem 2048
// > openssl rsa -in private.pem -outform PEM -pubout -out public.pem
$data = "String to encrypt";
$privKey = openssl_pkey_get_private('file:///path/to/private.pem');
$encryptedData = "";