Skip to content

Instantly share code, notes, and snippets.

View roybarber's full-sized avatar

Roy Barber roybarber

View GitHub Profile
@roybarber
roybarber / safe-actions.ts
Last active October 3, 2024 09:11
Next.js + Vercel Firewall - Rate Limit
import { unstable_checkRateLimit as checkRateLimit } from '@vercel/firewall'
import { DEFAULT_SERVER_ERROR_MESSAGE, createSafeActionClient,} from 'next-safe-action'
import { headers } from 'next/headers'
// Creating an action client using the createSafeActionClient function
export const actionClient = createSafeActionClient({
// Handling returned server errors
handleReturnedServerError(e) {
// If the error is an instance of Error, return its message
if (e instanceof Error) {
@roybarber
roybarber / makeRequest.js
Created December 17, 2021 15:32
Reusable ES6 Javascript API module using Axios - Promise
//////////////////////////////////////
// Generic service like function for
// Api requests using axios
// @param {String} url - api url
// @param {String} method - E.g POST, GET
// @param {Body} body - form body if needed
// @returns {Promise} data
//////////////////////////////////////
export const makeRequest = (url, method, body) => {
url = encodeURI(url)
<!--Konto erstellen-->
<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Titel</title>
</head>
<body>
<h1>Platzhalter Nummer 1</h1>
<!--Kontakt-->
<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Titel</title>
</head>
<body>
<h1>Platzhalter Nummer 1</h1>
@roybarber
roybarber / testgist.html
Last active May 1, 2017 10:15
Test Embed Gist
<!--Konto Erstellen-->
<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Titel</title>
</head>
<body>
<h1>Platzhalter Nummer 1</h1>
@roybarber
roybarber / transform-hack.css
Created January 13, 2014 19:18
Enable hardware acceleration on an animated element by using the “null transform hack”.
.element {-webkit-transform: translateZ(0);-moz-transform: translateZ(0);transform: translateZ(0);}
@roybarber
roybarber / vertical-align-mixin.scss
Created January 13, 2014 19:15
Vertical Align Anything
@mixin vertical-align {position: relative;top: 50%;-webkit-transform: translateY(-50%);-moz-transform: translateY(-50%);-ms-transform: translateY(-50%);transform: translateY(-50%);}
.element {@include vertical-align;}
desc "Pull a database dump from remote server, drop the local database, then import the dump"
task :pull_database_to_local do
# Build out temporary file name with timestamp for uniqueness
timestamp = get_timestamp
temp_file_name = "database_dump_#{timestamp}"
remote_file_name = remote_mysqldump(temp_file_name)
download(remote_file_name, "/tmp/#{temp_file_name}.sql.gz")
desc "Pull a database dump from remote server, drop the local database, then import the dump"
task :pull_database_to_local do
# Build out temporary file name with timestamp for uniqueness
timestamp = get_timestamp
temp_file_name = "database_dump_#{timestamp}"
remote_file_name = remote_mysqldump(temp_file_name)
download(remote_file_name, "/tmp/#{temp_file_name}.sql.gz")
@roybarber
roybarber / sprites.css
Created February 3, 2013 16:15
Output of the _sprites.scss file
.core-sprite, .core-icon-facebook, .core-icon-linkedin, .core-icon-skype, .core-logo { background: url('../img/core-s323b60b8ee.png') no-repeat; }
.core-icon-facebook { background-position: 0 -113px; height: 32px; width: 32px; }
.core-icon-linkedin { background-position: 0 -81px; height: 32px; width: 32px; }
.core-icon-skype { background-position: 0 -49px; height: 32px; width: 32px; }
.core-logo { background-position: 0 0; height: 49px; width: 179px; }