Skip to content

Instantly share code, notes, and snippets.

View jeaneric's full-sized avatar

jeaneric

  • AECOM
  • Gaspé, Québec, Canada
View GitHub Profile
@darknoon
darknoon / sign_s3_url.sql
Last active March 30, 2022 16:37
A function that lets you sign S3 urls for viewing from within your database queries
-- This function is based on this description:
-- https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html
CREATE OR REPLACE FUNCTION
sign_s3_url(
m_host text,
m_verb text,
m_resource text,
m_region text,
m_key text,
@loilo
loilo / pass-slots.md
Last active March 27, 2024 20:58
Vue: Pass Slots through from Parent to Child Components

Vue: Pass Slots through from Parent to Child Components

The Situation

  • We've got some components A, B and C which provide different slots.
    const A = {
      template: `<div><slot name="a">Default A Content</slot></div>`
    }

const B = {

@SagiMedina
SagiMedina / ImageTools.js
Last active March 25, 2024 06:13
Resize and crop images in the Browser with orientation fix using exif
import EXIF from 'exif-js';
const hasBlobConstructor = typeof (Blob) !== 'undefined' && (function checkBlobConstructor() {
try {
return Boolean(new Blob());
} catch (error) {
return false;
}
}());
@gurix
gurix / hstore_pivot.sql
Created April 9, 2014 10:01
Creating a cross tab / pivot table form hstore fields with dynamical column names using in postgresql
DROP TABLE IF EXISTS survey_sessions;
-- Imagine a table with survey sessions
-- token: some id or token to access a survey
-- answers: a key value store for answers
CREATE TABLE survey_sessions (
token text,
answers hstore);
-- We need some data to play with
INSERT INTO survey_sessions (token, answers) VALUES ('9IaxxP', 'a=>1, b=>2');
@jeaneric
jeaneric / smtp_relay.py
Last active December 31, 2015 23:29 — forked from TheBHump/smtp_relay.py
"""
SMTP->SES Relay Server
Author: Brian Humphrey, Loku.com
E-mail: bhump@loku.com
Date: August 17, 2011
A Lightweight SMTP server that accepts all messages and relays them to SES
Credit to http://www.doughellmann.com/PyMOTW/smtpd/ for a tutorial on smtpd with asyncore
anonymous
anonymous / gist:5814504
Created June 19, 2013 13:54
Batch upsert
WITH
-- write the new values
n(ip,visits,clicks) AS (
VALUES ('192.168.1.1',2,12),
('192.168.1.2',6,18),
('192.168.1.3',3,4)
),
-- update existing rows
upsert AS (
UPDATE page_views o
anonymous
anonymous / gist:5814404
Created June 19, 2013 13:39
better UPDATE
UPDATE election_results o
SET votes=n.votes, pro=n.pro
FROM ( VALUES (1,11,9),
(2,44,28),
(3,25,4)
) n(county_id,votes,pro)
WHERE o.county_id = n.county_id;