Skip to content

Instantly share code, notes, and snippets.

View gacha's full-sized avatar

Gatis Tomsons gacha

  • eazyBI
  • Ventspils, Latvia
View GitHub Profile
@gacha
gacha / switch_java.zsh
Created February 17, 2020 17:51
Simple function to switch java versions
function switch_java {
version=$1
if [[ $version -lt 10 ]]; then
version="1.$version"
fi
new_home=$(/usr/libexec/java_home -v $version 2&> /dev/null)
if [[ $new_home != $JAVA_HOME ]]; then
export JAVA_HOME=$new_home
echo "new JAVA_HOME=$JAVA_HOME"
fi

Keybase proof

I hereby claim:

  • I am gacha on github.
  • I am gacha (https://keybase.io/gacha) on keybase.
  • I have a public key ASCrGcx-v61gV4wEwku6NXXTclKvjmHW395CxFBIxUi-iwo

To claim this, I am signing this object:

@gacha
gacha / prepend.rb
Created February 25, 2019 10:20
ruby prepend
class Car
def info
# some long method
puts "Only some info"
end
end
module FullInfo
def enable
@show_full_info = true
"gcc -o conftest -I/usr/local/include/ruby-2.0.0/x86_64-linux -I/usr/local/include/ruby-2.0.0/ruby/backward -I/usr/local/include/ruby-2.0.0 -I. -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/usr/local/lib -L/usr/local/lib -lruby-static -lpthread -lrt -ldl -lcrypt -lm -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */

PostgreSQL setup

To use lv_LV.UTF-8 locale your unix system should have it, check it:

$ locale -a

If it's not here, then on linux as root uncomment it in /etc/locale.gen and run locale-gen. Then restart PostgreSQL server.

Open postgres shell:

@gacha
gacha / remove_encoding.sh
Created October 5, 2015 20:06
Remove old ruby encoding comment
find ./ -name *.rb | xargs -I{} ruby -i -ne 'print unless /^#\s?encoding:\s?utf-8/i' {}
(2..5).reduce(1){|m,o|y=10**o;m*((1..y).to_a.join[y-1].to_i)}
@gacha
gacha / stop-screensaver
Created December 20, 2014 19:59
Stop screensaver on linux
#!/bin/sh
export DISPLAY=:0.0
xset s off
xset s noblank
xset -dpms
@gacha
gacha / secret-santa.rb
Last active December 8, 2021 00:34
Secret santa script for christmas
#!/usr/bin/env ruby
require 'timeout'
members = %w(Gatis Jānis Anna Ilze Ieva Kaspars Juris Klāvs Pēteris)
takers = []
givers = []
exceptions = { 'Gatis' => 'Jānis'}
begin
Timeout::timeout(2) do
@gacha
gacha / nginx-proxy
Last active December 21, 2015 08:29
location @web {
proxy_redirect off;
proxy_set_header X-FORWARDED_PROTO http;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://web;
}