Skip to content

Instantly share code, notes, and snippets.

@29decibel
29decibel / livemd
Last active December 27, 2023 09:45
Extract donimant colors using dominant_colors in Elixir Livebook
# Extract dominant colors from image
```elixir
Mix.install([
{:kino, "~> 0.11.3"},
{:dominant_colors, "~> 0.1.4"}
])
```
@29decibel
29decibel / extractPDFCoverImage.ts
Last active September 9, 2023 16:30
Extract first page of the PDF as cover image
import fs from "fs";
import { PDFDocument } from "pdf-lib";
import { fromBuffer } from "pdf2pic";
import path from "path";
const OUTPUT_IMAGE_DPI = 200;
export async function extractPDFCoverImage(
pdfFilePath: string,
coverOutputPath: string
@29decibel
29decibel / .gitignore
Created October 31, 2022 00:33 — forked from adamgit/.gitignore
.gitignore file for Xcode4 / OS X Source projects
#########################
# .gitignore file for Xcode4 and Xcode5 Source projects
#
# Apple bugs, waiting for Apple to fix/respond:
#
# 15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation?
#
# Version 2.6
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
@29decibel
29decibel / build.mjs
Created March 8, 2022 17:51
Use Svelte in Phoenix the simple way
import esbuild from "esbuild";
import esbuildSvelte from "esbuild-svelte";
import sveltePreprocess from "svelte-preprocess";
import { readdir } from "fs/promises";
async function allSvelteComponents() {
const baseDir = "./js/app/";
const all = await readdir(baseDir);
return all.filter((f) => f.endsWith(".svelte")).map((f) => `${baseDir}${f}`);
}
this is an example gist
@29decibel
29decibel / run phoenix on amazon linux.sh
Last active September 27, 2016 03:30 — forked from eikes/run phoenix on amazon linux.sh
run phoenix on amazon linux
# app deps
sudo yum install git
# erlang deps
sudo yum groupinstall "Development Tools"
sudo yum install ncurses-devel
# erlang
wget http://www.erlang.org/download/otp_src_19.1.tar.gz
tar -zxvf otp_src_19.1.tar.gz
sudo yum -y install gcc gcc-c++ glibc-devel make ncurses-devel openssl-devel autoconf java-1.8.0-openjdk-devel git
sudo yum -y install wxBase.x86_64
sudo yum -y install wget
wget http://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
sudo rpm -Uvh erlang-solutions-1.0-1.noarch.rpm
sudo yum -y install esl-erlang
sudo mkdir /opt/elixir
sudo git clone https://github.com/elixir-lang/elixir.git /opt/elixir
cd /opt/elixir
sudo make clean test
@29decibel
29decibel / zhihu.recipe
Created March 13, 2016 16:21 — forked from zellux/zhihu.recipe
知乎日报 Kindle 版生成工具,可用于 Calibre
#!/usr/bin/env python
__copyright__ = 'Yuanxuan Wang <zellux at gmail dot com>'
from calibre.web.feeds.news import BasicNewsRecipe
from calibre.ebooks.BeautifulSoup import Tag, NavigableString
from collections import OrderedDict
from contextlib import nested, closing
import json
@29decibel
29decibel / API.md
Created February 5, 2016 08:12 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@29decibel
29decibel / gist:8678879
Last active January 4, 2016 21:09
vim stringify raw template
" little vim function
" make raw contents string
" turn following raw template
" <div class="show">
" <span>{{data.name}}</span>
" </div>
" into string:
" '<div class="show">' +
" '<span>{{data.name}}</span>' +
" '</div>'