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 / 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 / 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 / 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 / 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 / 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 / gist:8093753
Created December 23, 2013 09:02
Turn off Git auto line fix
git config --global core.autocrlf false
@hkraji
hkraji / gist:7526519
Last active December 28, 2015 16:09
Hash to OpenStruct nested convert
require 'ostruct'
def self.convert_data(elements)
results = []
if elements.is_a?(Array)
elements.each do |el|
results << deep_convert(el)
end
else
@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":
@hkraji
hkraji / rdebugrc
Last active December 24, 2015 07:18
Rdebugrc, ruby debug
### Ruby
## Breakpoint
# DEBUG SNIPPET >>> REMOVE <<<
require (RUBY_VERSION.match(/1\.8\..*/) ? 'ruby-debug' : 'debugger');Debugger.start; debugger
### System