Skip to content

Instantly share code, notes, and snippets.

View benjaminbojko's full-sized avatar

Benjamin Bojko benjaminbojko

View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active May 5, 2024 20:24
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@witmin
witmin / ffmpeg-mp4-to-animated-webp.md
Last active April 20, 2024 23:49
Convert MP4 file to animated WebP in ffmpeg

Convert MP4 file to animated WEBP file in ffmpeg CLI

1. Install ffmpeg CLI through homebrew

In terminal.app, install ffmpeg through homebrew

brew install ffmpeg

Validate the installation:

@adielfernandez
adielfernandez / contrast.frag
Last active February 8, 2018 20:40
Simple Contrast Adjustment Shader
#version 330 core
in vec2 vTexCoord0;
out vec4 oColor;
uniform sampler2D uTex0;
uniform vec2 uResolution;
uniform float uExponent; //good values will be between 5 and 15
uniform float uShift; //good values will be between 0 and 1
@benjaminbojko
benjaminbojko / glm_quat_angle_test.h
Last active August 24, 2017 17:06
GLM Quaternion angleAxis to angle vs roll
vector<float> degs = {60, 120, 180, 240, 300, 360, 420, 480, -60, -120, -180, -240, -300, -360, -420, -480};
// angleAxis -> angle
for (float deg : degs) {
float rad = glm::radians(deg);
glm::quat rot = glm::angleAxis(rad, glm::vec3(0, 0, 1));
std::cout << "angleAxis -> angle: " + to_string(deg) + " deg -> " + to_string(glm::degrees(glm::angle(rot))) + " deg" << std::endl;
}
// angleAxis -> roll
@alexeygrigorev
alexeygrigorev / vimeo-download.py
Created September 17, 2016 09:09
Downloading segmented video from vimeo
import requests
import base64
from tqdm import tqdm
master_json_url = 'https://178skyfiregce-a.akamaihd.net/exp=1474107106~acl=%2F142089577%2F%2A~hmac=0d9becc441fc5385462d53bf59cf019c0184690862f49b414e9a2f1c5bafbe0d/142089577/video/426274424,426274425,426274423,426274422/master.json?base64_init=1'
base_url = master_json_url[:master_json_url.rfind('/', 0, -26) + 1]
resp = requests.get(master_json_url)
content = resp.json()
@OSDTips
OSDTips / Set-PowerPlan.ps1
Last active February 9, 2023 17:12
Set-PowerPlan.ps1
$Powerplans = Get-WmiObject -Query "SELECT ElementName,InstanceID,ISActive FROM win32_powerplan" -Namespace root\cimv2\power
$Target = "High performance"
foreach ($Powerplan in $Powerplans) {
if ($Powerplan.ElementName -eq $Target) {
$Powerplan.ElementName
$Powerplan.InstanceID
$Powerplan.ISActive
$Changer = $Powerplan
break
@benjaminbojko
benjaminbojko / LinkedTextView.h
Last active March 21, 2024 18:22
UITextView Subclass to avoid Long-Press Delays with embedded Links
//
// LinkedTextView.h
//
// Created by Benjamin Bojko on 10/22/14.
//
// The MIT License (MIT)
//
// Copyright (c) 2014 Benjamin Bojko
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
@tracker1
tracker1 / 01-directory-structure.md
Last active May 4, 2024 19:55
Anatomy of a JavaScript/Node project.

Directory structure for JavaScript/Node Projects

While the following structure is not an absolute requirement or enforced by the tools, it is a recommendation based on what the JavaScript and in particular Node community at large have been following by convention.

Beyond a suggested structure, no tooling recommendations, or sub-module structure is outlined here.

Directories

  • lib/ is intended for code that can run as-is
  • src/ is intended for code that needs to be manipulated before it can be used
@benjaminbojko
benjaminbojko / color-workflow-tools.md
Last active August 29, 2015 14:05
Color Workflow Tools

Color Workflow Tools

No matter how well organized or spec'ed out a PSD is, there's always that point where you have to manually bring colors from design to code. Here are a few tools that have helped me get a seamless 360° workflow for dealing with colors in OS X.

Alfred 2 Colors Workflow

Amazing workflow by Tyler Eich that allows you to preview, modify and convert colors in a bunch of different color spaces and formats (rgb, hsl, hex, ...). Great if you want to convert those hex values to RGB for CSS.

@benjaminbojko
benjaminbojko / iOS Background Download Gotchas.md
Last active August 10, 2019 00:38
iOS Background Download Gotchas

iOS Background Download Gotchas

I've been doing some thorough investigations into setting up a solid background download process. Here are some of the gotchas I stumbled upon and wanted to capture:

Background Tasks

  • Only download and upload tasks are allowed to run in the background (no data tasks)
  • Once a download task completes, your app will have to move that task from its temporary location to a permament location (or process the data somehow); The temporary file will be deleted once the URLSession:downloadTask:didFinishDownloadingToURL: delegate method returns.

App Suspension

  • If your app is suspended, it will be re-launched whenever a background task completes