Skip to content

Instantly share code, notes, and snippets.

View atwong's full-sized avatar

Adrian atwong

  • Qwil
  • San Francisco
View GitHub Profile
@atwong
atwong / transcript.MD
Last active April 5, 2023 03:23
Chat Transcript

I have an issue with my Vue webapp. Can you help advise on better solution than the one I implemented?


Sure, I'd be happy to help! Please provide more details on the issue you're facing and the solution you've implemented so far. That way, I can understand the problem better and offer a more informed advice.


The simplified version of my app has a search bar (component) present on all pages. When a user enters a query into the search bar, the component uses the Vue router to programmatically navigate to a search URL, e.g. if the user enter "Carl Sagan", the app would navigate to "/search?q=Carl+Sagan"

--
-- Functions to generate an aggregate XOR of a UUID column [Postgres]
--
-- Useful to verify two tables are identical without computing
-- a full md5 checksum of entire table
--
-- Note, only uses the big-end 8 bytes of the UUID as there are
-- no 16-byte integers
--
-- Usage: select to_hex(aggrxoruuid(pk)) from mytable

Keybase proof

I hereby claim:

  • I am atwong on github.
  • I am adrianqwil (https://keybase.io/adrianqwil) on keybase.
  • I have a public key ASC3zg8_DTCC7Xex3jeJP3PUbDSOSGnOBLicYHAj9AnHYQo

To claim this, I am signing this object:

var Jimp = require("Jimp");
/*
* Compute Perceptual Hash of an Image
* Javascript equivalent of https://github.com/bjlittle/imagehash
*
* These hashes differ by ~1-3 Hamming distance from original python implementation
*
*/
@atwong
atwong / extractvideo.js
Last active August 16, 2023 10:08
Extract Multiple Screenshots Video
/*
* Extract multiple screenshots/frames from a video URL
* Params
* - vidURL : video URL
* - frOffsets : array of timestamps
* - frameWidth : screenshot width (default: video width)
* Returns
* - frames: object with offset => {imgUrl, blob}
*
* An multiple-frame extension of http://cwestblog.com/2017/05/03/javascript-snippet-get-video-frame-as-an-image/
angular.module('aw.scroll-end', []).
directive('awscrollend', [function() {
return {
controller: ['$scope', '$element', function($scope, $element) {
$element.scroll(function(){
var scrollHeight = $element.prop("scrollHeight");
var clientHeight = $element.prop("clientHeight");
var remainder = scrollHeight - $element.scrollTop();
if (remainder == clientHeight) {
$scope.$emit('scrollend', $element);