This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useState } from "react"; | |
export default function useStatefulPromise( | |
callback: () => Promise<any>, | |
autoload = true | |
) { | |
const [error, setError] = useState<any>(); | |
const [pending, setPending] = useState(true); | |
const [preload] = useState<boolean>(autoload); | |
const [result, setResult] = useState<any>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useState } from 'react'; | |
/** | |
* @return {{width: Number, height: Number}} | |
*/ | |
function getWindowSize() { | |
return { | |
width: window.innerWidth, | |
height: window.innerHeight, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Base64 encoded username:password/pat | |
const credentials = "dmFpYmhhdnBhbmRleXZwejpjbGVhcmx5X25vdF9zZWNyZXQ="; | |
const defaults = { | |
contentType: "application/json", | |
headers: {"Authorization": "Basic " + credentials}, | |
muteHttpExceptions: true | |
}; | |
const server = "example.atlassian.net"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mklink /J public\storage storage\app\public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useState } from 'react'; | |
function useDataLoader(promise, options) { | |
const { autoload } = { autoload: true, ...options }; | |
const [error, setError] = useState(null); | |
const [loading, setLoading] = useState(!!autoload); | |
const [result, setResult] = useState(null); | |
function action() { | |
setLoading(true); | |
setError(null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
localBackupDir=${LOCAL_BACKUP_DIR:-$HOME/backup} | |
remoteBackupDir=${REMOTE_BACKUP_DIR:-backups} | |
dbHost=${DB_HOST:-localhost} | |
dbPort=${DB_PORT:-3306} | |
echo "Changing to '$localBackupDir'..." | |
cd "$localBackupDir" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var array1 = [1, 3, 4]; | |
var array2 = [5, 4, 2]; | |
var existing = []; | |
for (var i = 0; i < array1.length; i++) { | |
var key = array1[i]; | |
existing[key] = true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CERTIFICATES=`openssl s_client -servername $1 -host $1 -port 443 -showcerts </dev/null 2>/dev/null | sed -n '/Certificate chain/,/Server certificate/p'` | |
CURSOR=$CERTIFICATES | |
while [[ "$CURSOR" =~ '-----BEGIN CERTIFICATE-----' ]] | |
do | |
CERTIFICATE="${CURSOR%%-----END CERTIFICATE-----*}-----END CERTIFICATE-----" | |
CURSOR=${CURSOR#*-----END CERTIFICATE-----} | |
echo `echo "$CERTIFICATE" | grep 's:' | sed 's/.*s:\(.*\)/\1/'` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Support\Facades\Storage; | |
$public = Storage::disk('public'); | |
$s3 = Storage::disk('s3'); | |
$files = $public->files(null, true); | |
foreach ($files as $file) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.vaibhavpandey.trimview; | |
import android.content.Context; | |
import android.content.res.TypedArray; | |
import android.graphics.Bitmap; | |
import android.graphics.Canvas; | |
import android.media.MediaMetadataRetriever; | |
import android.media.ThumbnailUtils; | |
import android.net.Uri; | |
import android.os.Build; |