Skip to content

Instantly share code, notes, and snippets.

View ctkdev's full-sized avatar
💭
Attending Microsoft Build 2024

Christopher T. Kwiatkowski ctkdev

💭
Attending Microsoft Build 2024
View GitHub Profile
SELECT
table_schema as `Database`,
table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES
ORDER BY (data_length + index_length) DESC;
@ctkdev
ctkdev / SetRestrictedReadWritePolicy.groovy
Created November 7, 2015 20:41
Java SDK Set an Amazon s3 bucket policy that will allow the uploading and downloading of files from all IAM users granted access to the Amazon S3 Service.
@Grapes(
[
@Grab(group='com.amazonaws', module='aws-java-sdk-s3', version='1.10.32')
]
)
AmazonS3 s3Client = new AmazonS3Client()
final static String S3_BUCKET = "my-s3-bucket"
Statement allowRestrictedReadStatement = new Statement(Statement.Effect.Allow)
@ctkdev
ctkdev / MySQL_Insert_Into_From_Select.sql
Last active November 2, 2015 21:14
MySQL INSERT INTO with SELECT
INSERT INTO company_user (id_company, id_user)
SELECT
(SELECT company.id
FROM company
WHERE company.name = '') AS id_company,
user.id AS id_user
FROM user
WHERE user.id NOT IN (SELECT company_user.id_user
FROM company_user);
@ctkdev
ctkdev / MySQL_Date_Math_Subtraction_Example.sql
Created October 27, 2015 14:55
MySQL query that returns a timestamp that is exactly 1 day ahead of the current date/time
SELECT DATE_SUB(now(), INTERVAL '1' DAY);
@ctkdev
ctkdev / ListAllFiles.java
Created October 27, 2015 13:19
List all files including sub-directories in a Spring Web Application
String rootPath = request.getServletContext().getRealPath(File.separator);
LOGGER.warn("ROOT PATH: " + rootPath);
File rootDir = new File(rootPath);
System.out.println(rootDir.getAbsolutePath());
System.out.println("Getting all files in " + rootDir.getAbsolutePath() + " including those in subdirectories");
Collection<File> files = FileUtils.listFiles(rootDir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
for (File file : files) {
LOGGER.warn("iScribes FILE: " + file.getAbsolutePath());
}