Skip to content

Instantly share code, notes, and snippets.

View HarrisonJackson's full-sized avatar

Harrison Jackson HarrisonJackson

View GitHub Profile
@rphlmr
rphlmr / helpers.ts
Last active October 28, 2024 17:08
Drizzle ORM, deep sub queries
/* -------------------------------------------------------------------------- */
/* More here; */
/* -------------------------------------------------------------------------- */
// https://gist.github.com/rphlmr/0d1722a794ed5a16da0fdf6652902b15
export function distinctOn<Column extends AnyColumn>(column: Column) {
return sql<Column["_"]["data"]>`distinct on (${column}) ${column}`;
}
export function jsonBuildObject<T extends SelectedFields>(shape: T) {
@rphlmr
rphlmr / clear-db.ts
Last active October 29, 2024 14:47
Drizzle snippets
// Credits to Louistiti from Drizzle Discord: https://discord.com/channels/1043890932593987624/1130802621750448160/1143083373535973406
import { sql } from "drizzle-orm";
const clearDb = async (): Promise<void> => {
const query = sql<string>`SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'public'
AND table_type = 'BASE TABLE';
`;
@xxxxlr
xxxxlr / React-Native-WebView-Cookies.js
Created July 27, 2017 01:10 — forked from kanzitelli/React-Native-WebView-Cookies.js
React Native Trick: Get Cookies of WebView without using any native modules such as react-native-cookies. Might be helpful for getting JWT while making OAuth2 👽
// @flow
import React, { Component } from 'react';
import {
WebView,
} from 'react-native';
class LoginScreen extends Component {
state = {
cookies : {},
@ideasasylum
ideasasylum / translate_amazon.js
Last active July 30, 2020 23:18
Translate Amazon service names into plain English (see https://www.expeditedssl.com/aws-in-plain-english)
// ==UserScript==
// @name Translate Amazon
// @namespace http://your.homepage/
// @version 0.1
// @description Translate the Amazon service names into plain English. See https://www.expeditedssl.com/aws-in-plain-english
// @author @ideasasylum
// @match https://*.console.aws.amazon.com/console/home?*
// @grant none
// ==/UserScript==
@delphyne
delphyne / Vagrantfile
Created April 9, 2014 17:12
Vagrantfile snippet that allows you to use protected s3 boxes without having to go through the manual download/add shennanigans. Tested with Vagrant 1.4.3. Before using, you'll need to ```vagrant plugin install aws-sdk```.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.require_plugin "aws-sdk"
def get_box_download_url(bucket, key)
s3 = AWS::S3.new
bucket = s3.buckets[bucket]
box = bucket.objects[key]
url = box.url_for(:read, {:expires => (60*30), :secure => true})
url.to_s()
@jamesjennings
jamesjennings / gist:6613083
Created September 18, 2013 18:09
Script for transcoding, segmenting and preparing a video file for HLS playback. Used as a demo at 360iDev Denver 2013. Depends on HandBrakeCLI (from http://handbrake.fr/downloads2.php) and Apple's HLS tools (from https://developer.apple.com/streaming/)
HandBrakeCLI --input tears_of_steel_720p.mkv --output 5000.mp4 --encoder x264 -b 5000 --srt-file TOS-en.srt --x264-preset ultrafast
HandBrakeCLI --input tears_of_steel_720p.mkv --output 500.mp4 --encoder x264 -b 500 --srt-file TOS-en.srt --x264-preset ultrafast
HandBrakeCLI --input tears_of_steel_720p.mkv --output 50.mp4 --encoder x264 -b 50 --srt-file TOS-en.srt --x264-preset ultrafast
HandBrakeCLI --input tears_of_steel_720p.mkv --output 5.mp4 --encoder x264 -b 5 --srt-file TOS-en.srt --x264-preset ultrafast
mkdir 5000Kbps
mediafilesegmenter -t 10 -f 5000Kbps/ -I 5000.mp4
mkdir 500Kbps
mediafilesegmenter -t 10 -f 500Kbps/ -I 500.mp4
mkdir 50Kbps
@randyjensen
randyjensen / sublime_pref
Created July 26, 2013 21:02
Sublime Text User Preferences File
{
"bold_folder_labels": true,
"detect_slow_plugins": false,
"caret_style": "phase",
"ensure_newline_at_eof_on_save": true,
"file_exclude_patterns":
[
".DS_Store",
".gitkeep",
"dump.rdb"