Skip to content

Instantly share code, notes, and snippets.

View elitan's full-sized avatar

Johan Eliasson elitan

View GitHub Profile
@elitan
elitan / main.md
Created January 2, 2024 10:11
Clerk: Blocked due to unauthorized request (401)
@elitan
elitan / main.sh
Created January 1, 2024 14:55
Find active snapback domains from IIS
#!/bin/bash
# URL containing the list of domains and dates
URL="https://data.internetstiftelsen.se/bardate_domains.txt"
echo "Starting script..."
echo "Downloading domain list from $URL..."
# Download the file and sort the entries by date
sorted_entries=$(curl -s "$URL" | sort)
@elitan
elitan / utils.ts
Created November 5, 2023 10:13
Parse Open AI function calls JSON response with JavaScript/TypeScript
function escapeNewLines(str: string) {
return str.replace(/\n/g, '\\n');
}
function fixOpenAiNewLineResponse(str: string) {
return str
.split('"')
.map((chunk, index) => {
// Only replace \n inside the JSON string values, which are in every other index after splitting by "
if (index % 2 === 1) {
import React, { Component } from 'react';
import { Redirect } from 'react-router-dom';
import { ApolloProvider } from 'react-apollo';
import { InMemoryCache } from 'apollo-cache-inmemory';
import ApolloClient from 'apollo-client';
import { setContext } from 'apollo-link-context';
import { WebSocketLink } from 'apollo-link-ws';
import { HttpLink } from 'apollo-link-http';
import { split } from 'apollo-link';
@elitan
elitan / gist:71b82bd809df81f34a9a778807782437
Created December 29, 2017 12:26
Ubuntu Bose QC35 bluetooth problem
> cat /etc/bluetooth/main.conf
ControllerMode = bredr
Disable=Headset
AutoConnect=true
Also:
https://askubuntu.com/questions/689281/pulseaudio-can-not-load-bluetooth-module-15-10-16-04-16-10
@elitan
elitan / ContactForm.js
Last active November 9, 2022 05:21
React Router V4 Redirect after form submission
import React, { Component } from 'react';
import { withRouter } from 'react-router-dom'; // <--- import `withRouter`. We will use this in the bottom of our file.
class ContactForm extends Component {
submitForm (e) {
e.preventDefault()
this.props.history.push('/thank-you'); // <--- The page you want to redirect your user to.
}
function timeElapsedString($ptime)
{
$etime = time() - $ptime;
if ($etime < 1)
{
return '0 seconds';
}
$a = array( 12 * 30 * 24 * 60 * 60 => 'år,år',