Skip to content

Instantly share code, notes, and snippets.

View LucasHild's full-sized avatar

Lucas Hild LucasHild

View GitHub Profile
@robinpokorny
robinpokorny / parseUuid7Date.js
Created May 8, 2023 12:30
Validate UUIDv7 and parse the timestamp
const uuid7Re = /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
const parseUuid7Date = (uuid) => {
if (typeof uuid !== `string` || !uuid7Re.test(uuid)) {
throw new TypeError(`Expected UUIDv7. Received: ${String(uuid)} (${typeof uuid})`)
}
const timestampHex = uuid.slice(0, 13).replace(`-`, ``)
const timestamp = Number.parseInt(timestampHex, 16)
return new Date(timestamp)
@tobywf
tobywf / clean_old_lambda_versions.py
Last active September 9, 2024 17:50
A quick script to remove old AWS Lambda function versions
from __future__ import absolute_import, print_function, unicode_literals
import boto3
def clean_old_lambda_versions():
client = boto3.client('lambda')
functions = client.list_functions()['Functions']
for function in functions:
versions = client.list_versions_by_function(FunctionName=function['FunctionArn'])['Versions']
for version in versions:
@nickpiesco
nickpiesco / README.md
Created October 16, 2015 14:46
DRY out Media Queries with React and Radium

Here at Bloomfire, we’re loving building new components with React. We’re even going all in with using ES6 modules and inline styles. (‘Inline styles?!’ I hear you say? Don’t knock it ’til you’ve tried it.)

There’s a lot of cool stuff we can do with CSS that we can’t do with inline styles, though; and that’s where Radium comes in. Radium not only provides a handy way to style :hover, :focus, and :active states, but it also deftly handles media queries. If you’re using inline styles in React and not using Radium, you should. I’ll give you a minute to go look it over – here’s the link again.

Back? Okay.

We create a style object in each of our React components, which we then reference in the JSX below. Here’s a super-stripped-down example:

// [myAwesomeButton.js]
@todgru
todgru / aws-ec2-redis-cli.md
Created June 12, 2014 23:01
AWS redis-cli on EC2
@ecsyz
ecsyz / new_gist_file.java
Created October 8, 2013 08:38
swing-button-ActionListener-inline
nameButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
nameButtonActionPerformed(evt);
}
});
@snim2
snim2 / pre-commit.py
Created September 5, 2013 00:50
A git pre-commit hook to test Python code for PEP8 compliance, and run unit tests via the pytest framework
#!/usr/bin/env python
"""
Git pre-commit hook to enforce PEP8 rules and run unit tests.
Copyright (C) Sarah Mount, 2013.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
@geoffalday
geoffalday / secretkey.py
Created March 12, 2012 12:28
How to generate a secret key with Python
# How to generate a secret key with Python
# via http://flask.pocoo.org/docs/quickstart/
import os
os.urandom(24)