Skip to content

Instantly share code, notes, and snippets.

@jgram925
jgram925 / C# Winform - Calling a form function from another form.md
Last active October 19, 2023 16:21
C# Winform - Calling a form function from another form.md
public partial class MainForm : Form
{        
    public void refreshInventoryDGV()
    {
        // function that will be used in other form
    }
    
    private void addButton_Click(object sender, EventArgs e)
    {

// need to pass "this" form instance to other form

@jgram925
jgram925 / C# Database Connection Notes.md
Last active November 30, 2020 22:06
C# Database Connection Notes.md

Example SQL Set Data

string connString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Joswar\source\repos\C898_Capstone\InventoryDB.mdf;Integrated Security=True";
string queryString = $"INSERT INTO Inventory ([Id], [Name], [Product Number], [Description], [Quantity], [Expiration Date], [Record Modified]) VALUES (7, '{nameInput.Text}', {Convert.ToInt32(productNumberInput.Text)}, '{descriptionInput.Text}', {Convert.ToInt32(quantityInput.Text)}, '{expirationDateInput.Text}', '{DateTime.Now}')";
SqlConnection conn = new SqlConnection(connString);
conn.Open();

SqlCommand cmd = new SqlCommand(queryString, conn);

@jgram925
jgram925 / Multiple Pages on Tkinter.md
Last active September 30, 2022 02:42
Multiple Pages on Tkinter.md

This is an example from StackOverflow (link provided below), from the user Bryan Oakley. This not a solution provided by myself. Thank you Bryan for providing this useful info! StackOverflow Link

import tkinter as tk

class Page(tk.Frame):
    def __init__(self, *args, **kwargs):
        tk.Frame.__init__(self, *args, **kwargs)

def show(self):

@jgram925
jgram925 / jQuery Custom Attributes.md
Last active October 30, 2019 20:49
jQuery Custom Attributes.md

HTML

<a cust_attr="{{ ctxt.val }} href="#">CLICK ME!</a>

jQuery

var cust_attr = $(this).attr('cust_attr');

@jgram925
jgram925 / Incrementally Reduce PLC Integer with Timer & Reset.md
Last active August 30, 2019 20:53
Incrementally Reduce PLC Integer with Timer & Reset.md

Incrementally Reduce INT with Timer and Reset

Image of the ladder logic is hosted in the comments.

@jgram925
jgram925 / z3c.rml QR Codes.md
Created August 30, 2019 17:06
z3c.rml QR Codes.md

In the view

Use the build_absolue_uri to get the server address regardless of any changes.

qr_code = request.build_absolute_uri('/pms/{}'.format(pk))

Pass the 'qr_code' variable into the context.

On the PDF template

Call the 'qr_code' context in the barCodeFlowable tag's value atribute.

@jgram925
jgram925 / Click Event on Dynamically Generated Button.md
Created August 29, 2019 20:25
Click Event on Dynamically Generated Button.md
$("#pm-table").on("click", ".pm_auto_complete", function(){

Instead of the selecting the button itself, the parent element should be selected. Then select the class/id of the element in the ON event.

@jgram925
jgram925 / Django auth with Active Directory.md
Last active August 21, 2019 19:45
Django auth with Active Directory.md

This will require that Windows Server Domain Services Active Directory be setup. In this tutorial LDAP will be accessing the server unsecurely but if an SSL cert is created it can be done securely as well. It is also a good idea to create a custom group to query so that Administrator accounts aren't pulled into the Django Authenication system. Most of the heavely lifting done using the etianen/django-python3-ldap app.

  1. Install using pip install django-python3-ldap.
  2. Add 'django_python3_ldap' to your INSTALLED_APPS setting.
  3. Set your AUTHENTICATION_BACKENDS setting to ("django_python3_ldap.auth.LDAPBackend", "django.contrib.auth.backends.ModelBackend",)
  4. Configure the settings for your LDAP server (as described on site).
  5. Optionally, run python manage.py ldap_sync_users to perform an initial sync of LDAP users.

AUTHENTICATION_BACKENDS = ("django_python3_ldap.auth.LDAPBackend", "django.contrib.auth.backends.ModelBackend",)

@jgram925
jgram925 / Modal with Cookies in Django.html
Last active July 18, 2019 18:34
Modal with Cookies in Django.html
<!--
VIEWS.PY
#Check for of Get Cookie
ps_cookie_value = request.COOKIES.get('ps_cookie')
#Construct Initial Cookie Value or Join
if not ps_cookie_value:
ps_cookie_value = str(packing_slip.id)