Skip to content

Instantly share code, notes, and snippets.

View dreyfus92's full-sized avatar
🍬
sugar, we're goin down

Paul Valladares dreyfus92

🍬
sugar, we're goin down
View GitHub Profile
@trvswgnr
trvswgnr / compress_video
Last active February 5, 2025 20:37
portable shell script to compress videos with ffmpeg
#!/bin/sh
print_usage() {
echo "usage: compress_video <input_file>"
echo "supported formats: mp4, webm, mkv, mov, avi, flv"
}
get_extension() {
f="${1##*/}"
case "$f" in
@WarrenBuffering
WarrenBuffering / useFetchStatus.ts
Last active September 4, 2023 23:47
goated hooks
import { useCallback, useMemo, useState } from 'react';
import { FetchStatus } from '../enums';
export function useFetchStatus() {
const [errorCode, setErrorCode] = useState<number | null>(null);
const [errorMessage, setErrorMessage] = useState<string>('');
const [status, setStatus] = useState<FetchStatus>(FetchStatus.UNFETCHED);
const fail = useCallback((message: string, code?: number) => {
@trvswgnr
trvswgnr / SyncService.test.ts
Last active August 7, 2023 07:31
daxxer challenge 2
import { SyncService } from './SyncService';
import type {
EventId,
UserId,
EventFromA,
} from './types';
import { describe, beforeEach, it, expect } from '@jest/globals';
import { QueueService, LogService, BService, MonitorService, CacheService } from './mock-services';
[
{
"key": "cmd+d",
"command": "editor.action.deleteLines",
"when": "textInputFocus && !editorReadonly"
},
{
"key": "ctrl+shift+k",
"command": "-editor.action.deleteLines",
"when": "textInputFocus && !editorReadonly"
package views
import (
"context"
"fmt"
"log"
"net/http"
"strings"
"time"
@wtbarnes
wtbarnes / push-to-someone-elses-pr.md
Created March 5, 2020 04:49
Brief instructions for how to modify and push to someone else's PR on github

How to Push to Someone Else's Pull Request

Let's say contributor has submitted a pull request to your (author) project (repo). They have made changes on their branch feature and have proposed to merge this into origin/master, where

origin -> https://github.com/author/repo.git

Now say you would like to make commits to their PR and push those changes. First, add their fork as a remote called

@bbqtd
bbqtd / macos-tmux-256color.md
Last active June 4, 2025 17:47
Installing tmux-256color for macOS

Installing tmux-256color for macOS

  • macOS 10.15.5
  • tmux 3.1b

macOS has ncurses version 5.7 which does not ship the terminfo description for tmux. There're two ways that can help you to solve this problem.

The Fast Blazing Solution

Instead of tmux-256color, use screen-256color which comes with system. Place this command into ~/.tmux.conf or ~/.config/tmux/tmux.conf(for version 3.1 and later):

@fiftin
fiftin / Convert PostgreSQL to SQLite
Created October 5, 2015 07:04
Convert PostgreSQL to SQLite
1. Dump the data only sql to file
$ pg_dump --data-only --inserts YOUR_DB_NAME > dump.sql
2. scp to local
3. Remove the SET statements at the top
such as:
SET statement_timeout = 0;
SET client_encoding = 'SQL_ASCII';
4. Remove the setval sequence queries
@bartholomej
bartholomej / css-media-queries-cheat-sheet.css
Last active June 14, 2025 23:51
CSS Media Query Cheat Sheet (with Foundation)
/*------------------------------------------
Responsive Grid Media Queries - 1280, 1024, 768, 480
1280-1024 - desktop (default grid)
1024-768 - tablet landscape
768-480 - tablet
480-less - phone landscape & smaller
--------------------------------------------*/
@media all and (min-width: 1024px) and (max-width: 1280px) { }
@media all and (min-width: 768px) and (max-width: 1024px) { }
@dvarrazzo
dvarrazzo / prepare.py
Created September 28, 2012 01:19
An example of psycopg2 cursor supporting prepared statements
#!/usr/bin/env python
"""An example of cursor dealing with prepared statements.
A cursor can be used as a regular one, but has also a prepare() statement. If
prepare() is called, execute() and executemany() can be used without query: in
this case the parameters are passed to the prepared statement. The functions
also execute the prepared statement if the query is the same prepared before.
Prepared statements aren't automatically deallocated when the cursor is
deleted, but are when the cursor is closed. For long-running sessions creating