Skip to content

Instantly share code, notes, and snippets.

@tkim90
tkim90 / http.ts
Last active September 27, 2023 13:00
typescript fetch pattern
// Source: https://www.carlrippon.com/fetch-with-async-await-and-typescript/
// Source: https://eckertalex.dev/blog/typescript-fetch-wrapper
interface HttpResponse<T> extends Response {
parsedBody?: T;
error?: T;
}
export async function http<T>(request: RequestInfo): Promise<HttpResponse<T>> {
const response: HttpResponse<T> = await fetch(request);
@vasilakisfil
vasilakisfil / deadpool_postgres.rs
Created July 20, 2020 11:48
deadpool postgres simple setup
use deadpool_postgres::tokio_postgres::NoTls;
use deadpool_postgres::{Config, ManagerConfig, Pool, PoolError, RecyclingMethod};
use once_cell::sync::Lazy;
use std::sync::Arc;
static DB_POOL: Lazy<Arc<Pool>> = Lazy::new(|| {
let mut cfg = Config::new();
cfg.dbname = Some(
std::env::var("DATABASE_URL")
.map_err(|_| String::from("Environment variable Database URL could not be read"))
@dnozay
dnozay / My Exiftool Cheatsheet.md
Last active November 12, 2023 15:48 — forked from rjames86/My Exiftool Cheatsheet.md
Cheatsheet for image / video metadata manipulation.

Cheatsheet for image / video metadata manipulation.

Last updated 2019-07-24

Disclaimer

until more specific license...

THE CONTENT BELOW IS PROVIDED "AS-IS",
WE DISCLAIM LIABILITY FOR ALL USES TO THE FULLEST EXTENT PERMITTED BY APPLICABLE LAW.
# frozen_string_literal: true
require 'rails_helper'
RSpec.configure do |config|
config.use_transactional_fixtures = false
# DatabaseCleaner settings
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
@mehaase
mehaase / sshtranger_things.py
Last active March 5, 2024 18:43
SSHtranger Things Exploit POC
'''
Title: SSHtranger Things
Author: Mark E. Haase <mhaase@hyperiongray.com>
Homepage: https://www.hyperiongray.com
Date: 2019-01-17
CVE: CVE-2019-6111, CVE-2019-6110
Advisory: https://sintonen.fi/advisories/scp-client-multiple-vulnerabilities.txt
Tested on: Ubuntu 18.04.1 LTS, OpenSSH client 7.6p1
We have nicknamed this "SSHtranger Things" because the bug is so old it could be
@sevaldes
sevaldes / sidekiq_cleaner.rb
Created December 4, 2017 13:46
Clear Sidekiq data
# inside a rails console
Sidekiq.redis { |conn| conn.flushdb }
@subfuzion
subfuzion / curl.md
Last active May 8, 2024 04:57
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

// Kotlin + HttpURLConnection
val connection = URL("https://api.github.com/user").openConnection() as HttpURLConnection
val auth = Base64.getEncoder().encode("user:pass".toByteArray()).toString(Charsets.UTF_8)
connection.addRequestProperty("Authorization", "Basic $auth")
connection.connect()
println(connection.responseCode)
println(connection.getHeaderField("Content-Type"))
val text = connection.inputStream.use { it.reader().use { reader -> reader.readText() } }
println(text)
@palkan
palkan / gist:d89757a90cfbeb047c63
Last active October 22, 2023 23:16
Rails debug cheat sheet

Setup

Replace IRB with Pry (in your Gemfile) and Byebug with pry-byebug.

gem 'pry-rails', group: [:development, :test]
gem 'pry-byebug', group: [:development, :test]

Using PRY

Last updated: 2017-03-18

Searching for Files

Find images in a directory that don't have a DateTimeOriginal

exiftool -filename -filemodifydate -createdate -r -if '(not $datetimeoriginal) and $filetype eq "JPEG"' .

###Output photos that don't have datetimeoriginal to a CSV### Note this can take a long time if you have a lot of jpgs