Skip to content

Instantly share code, notes, and snippets.

View hkraji's full-sized avatar

Haris Krajina hkraji

  • Cron
  • Sarajevo, Bosnia and Herzegovina
View GitHub Profile
@hkraji
hkraji / dtk-update.sh
Created February 17, 2014 13:08
dtk update
#!/usr/bin/env bash
for component in "dtk-client" "dtk-common" "dtk-common-repo" "server" "dtk-repo-manager" "dtk-admin-application" "common"
do
if [ -d "$HOME/$component" ]; then
echo "Updating $HOME/$component ..."
git --git-dir="$HOME/$component/.git" --work-tree="$HOME/$component" clean -f
git --git-dir="$HOME/$component/.git" --work-tree="$HOME/$component" checkout .
git --git-dir="$HOME/$component/.git" --work-tree="$HOME/$component" pull
fi
done
@hkraji
hkraji / dtk-build-client.sh
Last active August 29, 2015 13:56
DTK Build client
#!/usr/bin/env bash
if [ -z $1 ];
then
client_branch="master"
else
client_branch=$1
fi
if [ -z $2 ];
then
@hkraji
hkraji / gist:9090733
Created February 19, 2014 12:11
GIT RM ALL
UBUNTU SET RM ALL
alias rm-all='git rm $(git ls-files --deleted)'
WINDOWS SET RM ALL
doskey rm-all=bash -c "git rm $(git ls-files --deleted)"
@hkraji
hkraji / git_update_all.rb
Created February 28, 2014 12:33
Clean and Update all
#!/usr/bin/env ruby
require 'pp'
# no stdout buffering
STDOUT.sync = true
# checks for windows/unix for chaining commands
OS_COMMAND_CHAIN = RUBY_PLATFORM =~ /mswin|mingw|cygwin/ ? "&" : ";"
@hkraji
hkraji / utf8_normalization.rb
Created March 19, 2014 11:32
Normalize to UTF8 (remove invalid utf8 characters)
#
# Takes possible invalid UTF-8 output and ignores invalid bytes
#
# http://po-ru.com/diary/fixing-invalid-utf-8-in-ruby-revisited/
def self.normalize_to_utf8_output(response)
if response[:data]
ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')
output = response[:data][:output]||''
valid_output = ic.iconv(output + ' ')[0..-2]
@hkraji
hkraji / got.rb
Created March 20, 2014 12:05
Random Generation for GOT board game
houses = ['Lannister','Stark','Grayjoy','Baratheon','Tyrell','Martel']
players = ['Nera','Asaf','Keno','Aki','Haris','Zaharije']
while !houses.empty? do
puts "#{players.delete_at(rand(players.length))} :: #{houses.delete_at(rand(houses.length))}"
end
@hkraji
hkraji / remove_ssh.ruby
Created April 17, 2014 11:03
Remove ssh keys for dtk client
output = `dtk account list-ssh-keys`
output = output.split(/\n/)
output.each do |line|
match = line.match(/[0-9]+ \| (.*) \|/)
if match
identifier = match[1]
puts "Deleting #{identifier} ..."
puts `dtk account delete-ssh-key #{identifier}`
end
@hkraji
hkraji / Test.java
Created August 17, 2015 11:44
Za Kerima
import java.io.File;
import java.io.FileFilter;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(searchFile("test.pp", new File("/Users/haris/r8")));
require 'puppet'
puppet_params = {
:name => 'foo',
:ensure => 'present',
:key => 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDH1chpGVgtqgdXh62qS1V2g8Ic2nbpfXgzXAseObYYocOa0NIeCOmFxbMEhzT9h6/EhYTpF6tq0Gn8aBBd8gb90OlHdTIZ2j9IVhqLxmwnUJ3lwTbq6cEdVy1M/TM+A/TygRcqRrbNgoswGaVem
lfk7caeenN2KxG3vjzq5cCIAhGD7DeI9qQawZuKdJOCOgqUL6rF/J9nyyzPAS5uCeQumncGR+cfrywe9ZCUJrUbrWeYFHtB0d3XhbxCYJIqui3kMmbhQzsLGka9tcWQ1Zwm7VpcIrgerEyHO+0aNusG1szvxQkVWk1Bi7RI8fNLaogSq+HqkU2CRH
nEk7arJa9t',
:type => 'ssh-rsa',
:user => 'ubuntu'
@hkraji
hkraji / gist:6762413
Created September 30, 2013 11:22
Sublime Text 2 configuration
## User configuration
{
"bold_folder_labels": true,
"caret_style": "phase",
"color_scheme": "Packages/User/Monokai Soda.tmTheme",
"font_face": "DejaVu Sans Mono",
"font_size": 10.0,
"highlight_line": true,
"ignored_packages":