Skip to content

Instantly share code, notes, and snippets.

View cdracars's full-sized avatar
🎯
Focusing

Cody Dracars cdracars

🎯
Focusing
  • CFS Brands, LLC
  • Oklahoma City Oklahoma
  • X @cdracars
View GitHub Profile
@saralgyaan
saralgyaan / auto_delete
Created January 12, 2019 09:44
This script auto deletes messages from your gmail inbox.
#!/usr/bin/python3.6
"""AutoDelete
This script auto deletes messages from your gmail inbox.
The perfect usecase is deleting the OTP messages received from banks after certain time period.
or deleting the messages received from certain services which doesn't have unsubscribe option.
Many parts of this script are copied from EZGmail by Al Sweigart (https://github.com/asweigart/ezgmail)
"""
@ixdy
ixdy / yubikey4-ssh-macos.md
Last active April 12, 2024 20:19
Setting up ssh public key authentication on macOS using a YubiKey 4

Setting up ssh public key authentication on macOS using a YubiKey 4

I largely followed Florin's blog post, but have a few notes to add regarding issues I encountered:

Basic setup notes

  1. I used a YubiKey 4, while the blog describes using a YubiKey NEO. I'm sure a YubiKey 5 would also work. I'm also running macOS 10.13.6.
  2. I installed GPGTools as recommended. However, as I'll note later, it seems that gpg-agent only automatically starts when gpg is used; for ssh, you'll need to ensure it's running.
  3. Before generating your keys, decide what key size you want to use. If you run the list command inside gpg --edit-card, look for the Key attributes line to see what is currently selected. On my YubiKey 4, it defaulted to 2048 bits for all keys:
Key attributes ...: rsa2048 rsa2048 rsa2048
@RichardBronosky
RichardBronosky / touchid_sudo.sh
Last active April 18, 2024 03:17
Use TouchID for sudo on modern MacBook Pro machines
#!/bin/bash
# curl -sL https://gist.githubusercontent.com/RichardBronosky/31660eb4b0f0ba5e673b9bc3c9148a70/raw/touchid_sudo.sh | bash
# This script is ready to copy-paste in whole, or just the line above (without the leading #)
# Use TouchID for sudo on modern MacBook Pro machines
# This script adds a single line to the top of the PAM configuration for sudo
# See: https://apple.stackexchange.com/q/259093/41827 for more info.
touchid_sudo(){
@DiegoQueiroz
DiegoQueiroz / query_activedirectory.py
Last active October 18, 2023 10:43
Python-LDAP Query Active Directory Example (with paged results to prevent ldap.SIZELIMIT_EXCEEDED exception)
# -*- coding: utf-8 -*-
# requires python-ldap (usually pip install python-ldap)
# But this package requires OpenLDAP libraries, so it is a pain to install it on Windows.
# So, if you're on Windows, I recomment to use pre-compiled binaries with this command (virtualenv supported):
# pip install https://download.lfd.uci.edu/pythonlibs/h2ufg7oq/python_ldap-3.1.0-cp37-cp37m-win_amd64.whl
import ldap
from ldap.controls import SimplePagedResultsControl
@signalpoint
signalpoint / example.php
Last active July 16, 2022 23:41
Drupal 8 Set Message Example
<?php
// The drupal_set_message() function is being deprecated!
// @see https://api.drupal.org/api/drupal/core%21includes%21bootstrap.inc/function/drupal_set_message/8.5.x
// > Deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
// > Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
// In some custom code.
\Drupal::messenger()->addMessage('Say something else');
@gregjhogan
gregjhogan / curl-push-azure-storage-blob.sh
Created April 20, 2017 18:13
Push a file to a blob in an Azure storage account
curl -X PUT -T ./{file.dat} -H "x-ms-date: $(date -u)" -H "x-ms-blob-type: BlockBlob" "https://{storageaccount}.blob.core.windows.net/backups/{file.dat}?{sas-token}"
@ckabalan
ckabalan / best_bash_history.sh
Last active February 20, 2024 23:17
The Best Bash History Settings Ever
# /etc/profile.d/best_bash_history.sh
# Save 5,000 lines of history in memory
HISTSIZE=10000
# Save 2,000,000 lines of history to disk (will have to grep ~/.bash_history for full listing)
HISTFILESIZE=2000000
# Append to history instead of overwrite
shopt -s histappend
# Ignore redundant or space commands
HISTCONTROL=ignoreboth
# Ignore more
@joshmiller83
joshmiller83 / commerce_2_order.php
Created September 28, 2016 15:12
Create an order programmatically for Drupal Commerce 2.x
<?php
$order_type = "default";
$store_id = 1;
$uid = 0;
$entity_type_manager = \Drupal::service('entity_type.manager');
$order_storage = $entity_type_manager->getStorage('commerce_order');
$new_order = $orderStorage->create([
'type' => $order_type,
'store_id' => $store_id,
@ipbastola
ipbastola / clean-up-boot-partition-ubuntu.md
Last active April 3, 2024 06:54
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 
@ralphschindler
ralphschindler / README.md
Last active September 30, 2023 19:28
Docker For Mac Host Address Alias To Enable PHP XDebug (10.254.254.254 Trick)

Docker (Mac) De-facto Standard Host Address Alias

This launchd script will ensure that your Docker environment on your Mac will have 10.254.254.254 as an alias on your loopback device (127.0.0.1). The command being run is ifconfig lo0 alias 10.254.254.254.

Once your machine has a well known IP address, your PHP container will then be able to connect to it, specifically XDebug can connect to it at the configured xdebug.remote_host.

Installation Of IP Alias (This survives reboot)

Copy/Paste the following in terminal with sudo (must be root as the target directory is owned by root)...