Skip to content

Instantly share code, notes, and snippets.

View pajcho's full-sized avatar
:octocat:
Make it work, make it right, make it fast

Nikola Pajic pajcho

:octocat:
Make it work, make it right, make it fast
View GitHub Profile
@pajcho
pajcho / compress-videos.md
Created October 5, 2022 13:11
Compress Video Files

Install ffmpeg

  • brew install ffmpeg

Compress a video

Note that lower CRF values correspond to higher bitrates, and hence produce higher quality videos.

  • ffmpeg -i input.mp4 -c:v libx265 -preset fast -crf 28 output.mp4

Needed on macOS: to preserve compatibility encoding H.265/HEVC for QuickTime

  • ffmpeg -i input.mp4 -c:v libx265 -preset fast -crf 28 -tag:v hvc1 -c:a eac3 -b:a 224k output.mp4
@pajcho
pajcho / youtube-download.md
Last active January 24, 2022 21:12
Download youtube videos and playlists as MP3s

https://github.com/ytdl-org/youtube-dl

To download a video or a playlist as MP3s

youtube-dl --extract-audio --audio-format mp3 "{youtube-video-url or playlist-url}"

To continue playlist download after a failure

youtube-dl --extract-audio --audio-format mp3 --playlist-start 89 "{youtube-video-url or playlist-url}"
// You can paste this into https://www.sassmeister.com/ to get the desired output and test it in browser
// ----------------------------------------------------------
// Variables
// ----------------------------------------------------------
$class-prefix: 'dib';
$breakpoints: (
768px: sm,
@pajcho
pajcho / heic-to-jpg.md
Last active January 24, 2022 21:12
Convert HEIC to JPG
@pajcho
pajcho / killall
Created October 6, 2014 08:13
Check processes that listen on a port and kill them
lsof -n -i4TCP:$PORT | grep LISTEN
sudo killall $PROCESS
@pajcho
pajcho / script.txt
Created September 30, 2014 17:19
Flush DNS on Yosemite
sudo discoveryutil udnsflushcaches
@pajcho
pajcho / hashtags.php
Created April 30, 2014 13:18
Turn hashtags in text into links (excludes hashtags already in links)
<?php
$str = <<<STR
This is <a href="http://foo.com">This is #foo</a>.
Simple #html-stuff text <a href="http://foobar.com#baz">#simple</a>
<span class="simple">simple #simple text text</span>
STR;
@pajcho
pajcho / weather.php
Last active May 25, 2018 11:59
Get weather information based on IP
<?php
function get_client_ip()
{
$ipaddress = '';
if (getenv('HTTP_CLIENT_IP'))
$ipaddress = getenv('HTTP_CLIENT_IP');
else if (getenv('HTTP_X_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_X_FORWARDED_FOR');
else if (getenv('HTTP_X_FORWARDED'))
@pajcho
pajcho / Git assume unchanged
Created October 31, 2013 11:50
Ignore folders in git, used for tmp, logs, cache. Run as command from terminal
// Ignore folder
git update-index --assume-unchanged fuel/app/logs/
git update-index --assume-unchanged fuel/app/cache/
git update-index --assume-unchanged fuel/app/tmp/
// Un-Ignore folder
git update-index --no-assume-unchanged fuel/app/logs/
git update-index --no-assume-unchanged fuel/app/cache/
git update-index --no-assume-unchanged fuel/app/tmp/
@pajcho
pajcho / Sentry 2 multiple user types in FuelPHP.md
Created July 31, 2013 11:39
Sentry 2 multiple user types in FuelPHP framework

Get multiple Sentry instances in FuelPHP framework

I followed this gist (https://gist.github.com/leabdalla/5999421) to achieve the goal, but because Sentry 2 uses different approach to implement in FuelPHP than Laravel it needed some additional code. So here is a solution for that.

Note that this is not perfect solution, and it could break when we do composer update, because it depends on current Sentry version.

1. Create New Files

You will need to create this file structure: