This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## I just ran into this after initializing a Visual Studio project _before_ adding a .gitignore file (like an idiot). | |
## I felt real dumb commiting a bunch of files I didn't need to, so the commands below should do the trick. The first two commands | |
## came from the second answer on this post: http://stackoverflow.com/questions/7527982/applying-gitignore-to-committed-files | |
# See the unwanted files: | |
git ls-files -ci --exclude-standard | |
# Remove the unwanted files: | |
git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- from here: https://gallery.technet.microsoft.com/scriptcenter/Rebuild-and-Reorganize-7ff5624e | |
DECLARE | |
@fragPercentThreshold decimal(11,2), | |
@schemaName nvarchar(128); | |
-- Determine maximum fragmentation threshold and the schema to operate against | |
SET @fragPercentThreshold = 5.0; | |
SET @schemaName = N'dbo'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Accepted answer from here: https://stackoverflow.com/questions/5408156/how-to-drop-a-postgresql-database-if-there-are-active-connections-to-it | |
SELECT pg_terminate_backend(pg_stat_activity.pid) | |
FROM pg_stat_activity | |
WHERE pg_stat_activity.datname = '[your database name goes here]' | |
AND pid <> pg_backend_pid(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
####################################################################################################################### | |
# This Gist is some crib notes/tests/practice/whatever for talking to Active Directory via LDAP. The (surprisingly | |
# helpful) documentation for Net::LDAP can be found here: http://net-ldap.rubyforge.org/Net/LDAP.html | |
####################################################################################################################### | |
require 'rubygems' | |
require 'net/ldap' | |
####################################################################################################################### | |
# HELPER/UTILITY METHOD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.nio.ByteBuffer; | |
import java.util.UUID; | |
public class UuidAdapter { | |
public static byte[] getBytesFromUUID(UUID uuid) { | |
ByteBuffer bb = ByteBuffer.wrap(new byte[16]); | |
bb.putLong(uuid.getMostSignificantBits()); | |
bb.putLong(uuid.getLeastSignificantBits()); | |
return bb.array(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fizzBuzzMap = { | |
3: 'Fizz', | |
5: 'Buzz', | |
15: 'FizzBuzz' | |
}; | |
/** | |
* The classic "Fizz Buzz" game: Print a list of numbers from 1 to the upper limit, using the following rules: | |
* * If the number is divisible by 3 print "Fizz" | |
* * If the number is divisible by 5 print "Buzz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****************************************************************************************************************************** | |
I was watching a video of a guy reading an article (man... what fucking strange times we live in...) about developers missing | |
basic programming skills because they rely on npm packages to do the work for them. There are packages like left-pad, is-array, | |
is-positive-integer, etc. Apparently some change in the left-pad package broke a bunch of big-time repos (including React). | |
This is a link to said video: https://www.youtube.com/watch?v=NmHUjxKpD90 | |
My main take-aways from the article/video were: | |
* just because it's a package that gets downloaded a bunch of times doesn't mean it's good, quality code | |
* don't introduce a dependency if you don't need to | |
* an over-reliance on external dependencies: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Been going through the Learn C++ tutorial (https://www.learncpp.com/), and so far this seems to be a pretty good setup for | |
tasks.json in VS Code. This tasks.json file is specific for clang++ (I'm on macOS 13.x), so you may need to update the `args` | |
to suit your own environment. In particular, you will want to replace with {your application name here} with whatever you want | |
your build artifact to be named. | |
*/ | |
{ | |
"tasks": [ | |
{ | |
"type": "cppbuild", | |
"label": "C/C++: clang++ build active file", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I have several AWS profiles in my ~/.aws/config thus there are several access keys and secret keys in my | |
# ~/.aws/credentials file. Sometimes (e.g. when using kops or kubectl) I need to have the AWS_ACCESS_KEY_ID | |
# and AWS_SECRET_ACCESS_KEY environment variables set. There doesn't seem to be a way to use the aws cli to set these | |
# environment variables for me, so... well... here we are. | |
# | |
# This script will: | |
# * Look at the ~/.aws/credentials file for the specified profile | |
# * Get the next two lines beneath the profile name, which are the access_key_id and secret_key respectively | |
# * Export those two values as environment variables | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is the function I created that's a wee bit less shitty than the file above. I created a file called (oddly enough) | |
# ec2-instance-query.zsh and put it in my ~/.oh-my-zsh/custom directory. After sourcing my ~/zshrc, I have a fancy-pants | |
# function for querying EC2 instances and ElasticIP addresses for a given IP: | |
function ec2-instance-query() { | |
echo "Finding EC2 information for IP $1:" | |
for r in `aws ec2 describe-regions --output text | cut -f4 | grep "us-"` | |
do | |
aws ec2 describe-instances \ | |
--region $r \ | |
--filter "Name=network-interface.addresses.association.public-ip, Values=$1" \ |
NewerOlder