Skip to content

Instantly share code, notes, and snippets.

@sdvim
sdvim / qql-headless-setup.sh
Created October 8, 2022 19:25
Quick starting guide to generating QQLs on a local computer
#!/usr/bin/env bash
# Install node if you don't already have it.
#
# If you're not a developer, try the basic installer:
# https://nodejs.org/en/
#
# If you are a developer, consider nodenv:
# https://github.com/nodenv/nodenv#installation
@hoegertn
hoegertn / index.js
Last active December 23, 2021 03:16
Rich Social Sharing with CloudFront
exports.handler = (event, context, callback) => {
'use strict';
const request = event.Records[0].cf.request;
const userAgent = request.headers['user-agent'][0].value;
let prerender = 0;
// user agent is known social bot
if (userAgent.match(/baiduspider|twitterbot|facebookexternalhit|googlebot|bingbot|yandex|rogerbot|linkedinbot|embedly|quora link preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator/i)) {
prerender = 1;
}
@bradwestfall
bradwestfall / S3-Static-Sites.md
Last active April 10, 2024 16:40
Use S3 and CloudFront to host Static Single Page Apps (SPAs) with HTTPs and www-redirects. Also covers deployments.

S3 Static Sites

⚠ This post is fairly old. I don't keep it up to date. Be sure to see comments where some people have posted updates

What this will cover

  • Host a static website at S3
  • Redirect www.website.com to website.com
  • Website can be an SPA (requiring all requests to return index.html)
  • Free AWS SSL certs
  • Deployment with CDN invalidation
@maximilian-lindsey
maximilian-lindsey / express_in_electron.md
Last active March 29, 2024 22:46
How to run Express inside an Electron app

How to run Express inside an Electron app

You can run your Express app very easily inside your Electron app.

All you need to do is to:

  • place all the files of your Express app inside a new app folder in your_electron_app\resources\app
  • reconfigure the app.js file
  • refactor some relative pathes in your Express app

Git Cheat Sheet

Commands

Getting Started

git init

or

@kevinblake
kevinblake / DeviceTypeRedirect.cs
Created December 13, 2012 14:45
MVC4 action filter attribute to redirect to a different controller if a page is not valid for mobile/non-mobile context
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.WebPages;
namespace MyNamespace
{
public enum DeviceType {Mobile, Desktop}
public class DeviceTypeRedirect : ActionFilterAttribute
{
@barryokane
barryokane / sso_login_freshdesk.cs
Created May 17, 2012 11:08
SSO Login for Freshdesk support portal - ASP.Net C# Sample Code
protected void Page_Load(object sender, EventArgs e)
{
string url = GetSsoUrl(ConfigurationManager.AppSettings["FreshDesk.BaseUrl"], //including trailing slash
ConfigurationManager.AppSettings["FreshDesk.Secert"], user.UserName, user.Email);
Response.Redirect(url);
}
string GetSsoUrl(string baseUrl, string secert, string name, string email)
{
return String.Format("{0}login/sso/?name={1}&email={2}&hash={3}", baseUrl, Server.UrlEncode(name),
// Simple spreadsheet, with first sheet containing form submission repsonses
// when the form is submitted:
// 1) grab the latest response,
// 2) post it to a third party service via an HTTP POST
function testWebhook() {
var ss = SpreadsheetApp.openById(SPREADSHEET_ID);
var form=ss.getSheets()[0];
var lr=form.getLastRow();
var el=form.getRange(lr,2,1,1).getValue();
var t=el;