Skip to content

Instantly share code, notes, and snippets.

View tadas-s's full-sized avatar
🍍
( ⚆ _ ⚆ ) ┬───────┬

Tadas Sasnauskas tadas-s

🍍
( ⚆ _ ⚆ ) ┬───────┬
View GitHub Profile
@tadas-s
tadas-s / post-update
Created March 1, 2023 14:07
git post-update hook for building Rails app pushed over ssh into a bare VM
#!/usr/bin/sh
project_name="project-name-here"
project_root="${HOME}"
refname=${1}
rev=$(git rev-parse --short ${1})
this_release="${project_root}/${project_name}-${rev}"
mkdir -p ${this_release}
@tadas-s
tadas-s / database.yml
Created February 24, 2023 13:41
Simplified Rails database configuration
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
url: <%= ENV["DATABASE_URL"] %>
development:
<<: *default
test:
@tadas-s
tadas-s / rspec-single-file-scaffold.rb
Created August 6, 2020 08:38
An example of bundler's inline feature used with rspec
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile do
source 'https://rubygems.org'
gem 'rspec'
@tadas-s
tadas-s / Vagrantfile
Created October 27, 2017 12:39
Installing your personal dotfiles on each Vagrant VM you use
# Change this to suit your dotfiles setup and copy to your *HOST* machine: $HOME/.vagrant.d/Vagrantfile
Vagrant.configure(2) do |config|
# Mount your dotfiles to vagrant user's home folder (or wherever you want):
config.vm.synced_folder "#{ENV['HOME']}/dotfiles", '/home/vagrant/dotfiles'
# Install dotfiles on every 'vagrant provision' call.
# For example, let's imagine your your dotfiles have 'install.sh' script:
config.vm.provision 'shell', privileged: false, inline: '/home/vagrant/dotfiles/install.sh'
end
@tadas-s
tadas-s / index.html
Last active October 26, 2015 14:29 — forked from alexkalderimis/index.html
Custom mode RefME widget example
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<title>RefME Cite Button</title>
<script src="https://widget.refme-dev.com/scripts/refme-cite.js"></script>
</head>
<body>
<section>
<div class="col">
<div id="citation-button"></div>
@tadas-s
tadas-s / nocol
Created December 10, 2014 10:15
nocol
#!/bin/bash
# Strips colors/escape sequences from output
#
# Usage: annoying-color-producing-tool | nocol
sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
@tadas-s
tadas-s / gist:c247ac75e6418871455c
Created November 19, 2014 16:29
AngularJS + ui-router debug snippet
app.run(function($rootScope) {
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
console.group('$stateChangeStart ' + fromState.name + ' => ' + toState.name);
console.group('from:');
console.log(fromState);
console.log(fromParams);
console.groupEnd();
@tadas-s
tadas-s / debug_recipes.txt
Last active August 8, 2017 07:28
Debug recipes for Linux
# Quick debug network traffic between nginx and php-fpm
# Got from:
# http://systembash.com/content/simple-sysadmin-trick-using-tcpdump-to-sniff-web-server-traffic/
# Just a flow of everything looking like a string
tcpdump -nl -w - -i eth0 -c 500 port 9090 | strings
# Request heads
sudo tcpdump -nl -w - -i eth0 -c 500 port 9090 | strings | grep -E -A5 "^(GET|PUT|POST) "
# strace processes/sub-processes
@tadas-s
tadas-s / gist:dae6a8f506993da19993
Created July 7, 2014 08:34
xdebug cli script from vagrant machine
# Say project domain in PhpStorm is configured as example.org and your VM IP is xxx.xxx.xxx.yyy:
PHP_IDE_CONFIG=serverName=example.org php -dxdebug.remote_autostart=1 -dxdebug.remote_host=xxx.xxx.xxx.1 -f ./app/console.php -- console:args --go-here
# with xdebug log (useful for troubleshooting)
PHP_IDE_CONFIG=serverName=example.org php -dxdebug.remote_log="./xdebug.log" -dxdebug.remote_autostart=1 -dxdebug.remote_host=xxx.xxx.xxx.1 -f ./app/console.php -- console:args --go-here
@tadas-s
tadas-s / AppKernel.php
Last active August 29, 2015 14:00
Relocate tmp folder on Symfony2
<?php
use Symfony\Component\HttpKernel\Kernel;
class AppKernel extends Kernel
{
/* ... everything else is skipped ... */
public function getCacheDir()