Skip to content

Instantly share code, notes, and snippets.

@doccaico
doccaico / ffmpeg.sh
Created October 17, 2020 07:26
FFMPEG を使ってmp3からTwitterで使うmp4を作る (1枚の静止画を使って)
# width not divisible by 2 というエラーが出る場合は -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" を追加する
ffmpeg -loop 1 -i blue.jpg -i ~/Desktop/aa.mp3 -shortest -b:a 320000 -pix_fmt yuv420p -vcodec libx264 out.mp4
# そもそもアップロードできない
# ffmpeg -loop 1 -i black.jpg -i input.mp3 -shortest -b 1000k -vcodec libx264 out.mp4
# これだとtwitterでは音がきこえなかった
# ffmpeg -loop 1 -i black.jpg -i input.mp3 -shortest -b 1000k -acodec copy out.mp4
@doccaico
doccaico / link.md
Last active March 23, 2021 03:06
更新のあったリポジトリ
@doccaico
doccaico / get_access_token.bash
Created October 17, 2020 07:34
OAuth2 and Reddit API example using cURL
CLIENT_ID="****"
CLIENT_SECRET="****"
USER_NAME="****"
USER_PASSWORD="****"
curl -X POST -A "User agent" -d "grant_type=password&username=$USER_NAME&password=$USER_PASSWORD" --user "$CLIENT_ID:$CLIENT_SECRET" https://www.reddit.com/api/v1/access_token
# output
# {"access_token": "****", "token_type": "bearer", "expires_in":3600, "scope": "*"}
@doccaico
doccaico / raylib.md
Created October 18, 2020 12:43
How to use raylib on Linux

Download railib 3.0.0

$ curl -LJO https://github.com/raysan5/raylib/releases/download/3.0.0/raylib-3.0.0-Linux-amd64.tar.gz

Install to ~/local/raylib3.0.0

$ tar zxvf raylib-3.0.0-Linux-amd64.tar.gz 
$ cd raylib-3.0.0-Linux-amd64
$ mkdir ~/local/raylib3.0.0
# https://github.com/raysan5/raylib/blob/3.0.0/examples/physics/physics_demo.c
import raylib
{.define: PHYSAC_NO_THREADS.}
include raylib/physac
const
screenWidth = 800
screenHeight = 450
@doccaico
doccaico / Makefile.patch.3.0.0.diff
Last active October 30, 2020 08:45
NIM Build Memo (included PHYSAC and RAYGUI)
--- Makefile.org 2020-10-30 12:21:35.708751677 +0900
+++ Makefile 2020-10-30 12:25:05.313747229 +0900
@@ -574,15 +574,15 @@
raygui.o : raygui.c raygui.h gui_textbox_extended.h ricons.h
$(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -DRAYGUI_IMPLEMENTATION
raygui.c:
- echo '#define RAYGUI_IMPLEMENTATION' > raygui.c
echo '#include "$(RAYLIB_MODULE_RAYGUI_PATH)/raygui.h"' >> raygui.c
# Compile physac module
# https://github.com/raysan5/raylib/blob/3.0.0/examples/models/models_first_person_maze.c
#
# $ cd examples/models
# $ nim r -p:../../src models_first_person_maze.nim
import raylib
proc free(p: pointer) {.
importc, header: "<stdlib.h>".}
import strutils
# Go version: https://github.com/prologic/monkey-lang/blob/master/parser/parser_tracing.go
#
# when defined(trace): import ./parser_tracing
# [...]
# proc parseProgram(p: var Parser): PNode =
# when defined(trace): TRACE("parseProgram")
#
# $ nim r -d:trace src/parser.nim
@doccaico
doccaico / main.nim
Created November 20, 2020 10:58
Resource embedding in Nim (sdl2_nim)
import
sdl2/sdl,
sdl2/sdl_ttf as ttf
const
Title = "SDL2 App"
ScreenW = 640 # Window width
ScreenH = 480 # Window height
WindowFlags = 0
RendererFlags = sdl.RendererAccelerated or sdl.RendererPresentVsync
@doccaico
doccaico / hello.nim
Last active November 23, 2020 08:03
NimSvg
import nimsvg
const numFrames = 250
type
Move = enum
Up, Right, Down, Left
Obj = object
x: float
y: float