Skip to content

Instantly share code, notes, and snippets.

import json
# Function to convert chunks to SRT entries
def chunks_to_srt(chunks):
srt_entries = []
sequence_number = 1
for chunk in chunks:
start_time = chunk["timestamp"][0]
end_time = chunk["timestamp"][1]
@techforum-repo
techforum-repo / server.py
Last active April 20, 2023 17:30 — forked from razor-x/server.py
Python http.server that sets Access-Control-Allow-Origin header.
import os
import sys
import http.server
import socketserver
PORT = 8000
class HTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
def end_headers(self):
self.send_header('Access-Control-Allow-Origin', '*')
import os
import sys
from http.server import HTTPServer, SimpleHTTPRequestHandler
import ssl
PORT = 443
class HTTPRequestHandler(SimpleHTTPRequestHandler):
def end_headers(self):
self.send_header('Access-Control-Allow-Origin', '*')
import java.io.IOException;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import org.apache.sling.api.SlingHttpServletRequest;

General Commands

Run AEM in Debug Mode

java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -jar aem-sdk-quickstart-2021.10.5977.20211021T153528Z-211000.jar

Create JAR File

jar cfm bundle.jar META-INF\MANIFEST.MF *

import java.io.IOException;
import java.util.HashMap;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.api.resource.Resource;
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
import org.apache.sling.models.annotations.Exporter;
import org.apache.sling.models.annotations.injectorspecific.Self;
import org.apache.sling.models.annotations.Via;
import org.apache.sling.models.annotations.via.ResourceSuperType;
image: atlassian/default-image:2
clone:
depth: 'full'
pipelines:
branches:
dev:
- step:
script:
image: atlassian/default-image:2
pipelines:
branches:
dev:
- step:
script:
- git remote add sync https://testuser:[email protected]/test/test.git
- git checkout dev
- git pull

Facebook oEmbed API Reference

Get Page Embed - Client Access Token

curl -i -X GET "https://graph.facebook.com/v10.0/oembed_page?url={Page URL}&access_token={APP ID}|{Client Access Token}"
e.g. curl -i -X GET "https://graph.facebook.com/v10.0/oembed_page?url=https%3A%2F%2Fwww.facebook.com%2Ftechlogyforum&access_token=191545172686279|c98f87ecec83d6183004602be86410d7"