Skip to content

Instantly share code, notes, and snippets.

View brlo's full-sized avatar
🦎
...

Rodion V brlo

🦎
...
View GitHub Profile
@vi
vi / split_by_silence.sh
Last active February 23, 2024 13:18
Using FFmpeg to split multimedia file into parts based on audio volume level
#!/bin/bash
IN=$1
OUT=$2
true ${SD_PARAMS:="-55dB:d=0.3"};
true ${MIN_FRAGMENT_DURATION:="20"};
export MIN_FRAGMENT_DURATION
if [ -z "$OUT" ]; then
class Cache
@redis = {}
def self.fetch key, expires_in = 30, &block
puts ""
puts @redis
if @redis.key?(key) && (@redis[key][:expiration_time] > Time.now.to_i)
# fetch and return result
puts "fetch from cache and will expire in #{@redis[key][:expiration_time] - Time.now.to_i}"
@redis[key][:value]
else
@fhferreira
fhferreira / action.js
Created February 6, 2017 17:03
Copy html to clipboard with Format
function html2clipboard(html, el) {
var tmpEl;
if (typeof el !== "undefined") {
// you may want some specific styling for your content - then provide a custom DOM node with classes, inline styles or whatever you want
tmpEl = el;
} else {
// else we'll just create one
tmpEl = document.createElement("div");
// since we remove the element immedeately we'd actually not have to style it - but IE 11 prompts us to confirm the clipboard interaction and until you click the confirm button, the element would show. so: still extra stuff for IE, as usual.
@joseluisq
joseluisq / terminal-git-branch-name.md
Last active July 4, 2024 15:00
Add Git Branch Name to Terminal Prompt (Linux/Mac)

Add Git Branch Name to Terminal Prompt (Linux/Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {
@reganjohnson
reganjohnson / gist:1f6d93c4e3d09e4d5903
Last active March 19, 2018 14:21
Set Default Text Editor as Sublime 3
First, let's create the $ subl command
sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
Another option is to use duti (http://duti.org / https://github.com/moretension/duti).
Run brew install duti, save a file like this as ~/.duti:
com.sublimetext.3 public.plain-text all
com.sublimetext.3 public.unix-executable all
@icyleaf
icyleaf / ar_migrate.rb
Last active June 6, 2024 20:06
ActiveRecord type of integer (tinyint, smallint, mediumint, int, bigint)
# activerecord-3.0.0/lib/active_record/connection_adapters/mysql_adapter.rb
# Maps logical Rails types to MySQL-specific data types.
def type_to_sql(type, limit = nil, precision = nil, scale = nil)
return super unless type.to_s == 'integer'
case limit
when 1; 'tinyint'
when 2; 'smallint'
when 3; 'mediumint'
when nil, 4, 11; 'int(11)' # compatibility with MySQL default
@jrom
jrom / nginx.conf
Created February 7, 2012 17:14
nginx hack for multiple conditions
if ($request_uri = /) {
set $test A;
}
if ($host ~* teambox.com) {
set $test "${test}B";
}
if ($http_cookie !~* "auth_token") {
set $test "${test}C";
@shapeshed
shapeshed / unicorn
Created September 16, 2011 10:12
Unicorn / Monit setup
#!/bin/sh
set -e
# Example init script, this can be used with nginx, too,
# since nginx and unicorn accept the same signals
# Feel free to change any of the following variables for your app:
TIMEOUT=${TIMEOUT-60}
APP_ROOT=/path/to/your/app/current
PID=$APP_ROOT/tmp/pids/unicorn.pid
ENVIRONMENT=production
@mattd
mattd / gist:1006398
Created June 3, 2011 14:12
nginx try_files with a proxy_pass
server {
root /var/www/example.com/static;
server_name example.com;
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;
try_files /maintenance.html @proxy;
location @proxy {
proxy_pass http://127.0.0.1:10001;