Skip to content

Instantly share code, notes, and snippets.

@coryarmbrecht
coryarmbrecht / Get_Webp_Post_Jpeg.js
Created April 26, 2022 19:55
GET a webp image with Axios, convert stream to jpeg, and add to form for POST.
const form = new FormData();
const url = 'https://i.ytimg.com/vi/20u8EOBbmSk/hqdefault.jpg?sqp=-oaymwEbCKgBEF5IVfKriqkDDggBFQAAiEIYAXABwAEG&rs=AOn4CLBKHG0GyzmzLNJ-04e5KSIcXCJtBQ'
// Get an image from YouTube and return arraybuffer or stream
const getImageStream = await axios.get(`${url}`, { responseType: "arraybuffer" })
.then(async (data)=>{
const buffer = Buffer.from(data, 'binary')
/* // Doesn't work
// Get error: "Error: Input buffer has corrupt header:"
@coryarmbrecht
coryarmbrecht / is_installed.sh
Created April 6, 2019 08:20 — forked from JamieMason/is_installed.sh
Check if a program exists from a bash script.Thanks to twitter.com/joshnesbitt and twitter.com/mheap for the help with detecting npm packages.
#!/bin/bash
# Functions ==============================================
# return 1 if global command line program installed, else 0
# example
# echo "node: $(program_is_installed node)"
function program_is_installed {
# set to 1 initially
local return_=1
@coryarmbrecht
coryarmbrecht / gist:53a06934da3a4d46cd0b37e905a36105
Created April 18, 2018 17:24
react-native-camera, android 8.1.0, targetSdk 23
This file has been truncated, but you can view the full file.
Last login: Wed Apr 18 10:10:47 on ttys011
MacBook-Pro:mobile_2018_04_11 user$ adb logcat
--------- beginning of system
04-18 03:29:49.545 613 651 E FrameworkListener: read() failed (Connection reset by peer)
04-18 03:29:51.505 1021 1511 I chatty : uid=1000(system) Binder:1021_3 expire 11 lines
04-18 03:29:52.212 1021 12702 I chatty : uid=1000(system) Binder:1021_20 expire 15 lines
04-18 03:29:54.316 613 31518 W SocketClient: write error (Broken pipe)
04-18 03:31:39.890 1661 1661 I chatty : uid=1001(radio) com.android.phone expire 39 lines
04-18 03:32:02.726 1021 6056 I chatty : uid=1000(system) Binder:1021_1D expire 13 lines
04-18 03:36:12.618 613 651 E FrameworkListener: read() failed (Connection reset by peer)
module.exports = options => {
if (options.mode == 'production'){
return {
entry: 'src/index.js',
extractCSS: false,
filename: {
js: 'index.js'
},
format: 'umd',
@coryarmbrecht
coryarmbrecht / firebase_detect_data.js
Created September 14, 2016 17:56 — forked from cooljith91112/firebase_detect_data.js
Firebase: Detecting if data exists. This snippet detects if a user ID is already taken
function go() {
var userId = prompt('Username?', 'Guest');
checkIfUserExists(userId);
}
var USERS_LOCATION = 'https://SampleChat.firebaseIO-demo.com/users';
function userExistsCallback(userId, exists) {
if (exists) {
alert('user ' + userId + ' exists!');
.ceil(_.random(1,5, true),2); //Generate Random numbers between 1 & 5 with precision of 2. ex: 4.56
#page1:inactive #body-image-background {
opacity: 0;
background: url('image_page1.jpg') no-repeat cover cover;
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;
}
#page1:active #body-image-background {