George Opritescu

Developer from somewhere

generate chef repo

If you have chef dk, it’s as simple as:

chef generate repo chef_repo
Read More

Program received and didn't handle signal TRAP

If you happen to receive this error message:

Program received and didn't handle signal TRAP (5)

make sure you haven’t forgotten a debugger statement somewhere.

Read More

zsh range

for i in {16..32}; do echo $i; done
Read More
zsh

postgres sum more than one column

Found here:

SELECT COALESCE(col1,0) + COALESCE(col2,0)
FROM yourtable
Read More

hive create table from parquet file

Example of creating a hive table from a parquet file:

create external table mytable (name string,id int) STORED AS PARQUET LOCATION '/user/me/file.parquet'
Read More

python use unicode in doctest

Found this useful information here:

# -*- coding: utf-8 -*-
def mylen(word):
  u"""        <----- SEE 'u' HERE
  >>> mylen(u"áéíóú")
  5
  """
  return len(word)

print mylen(u"áéíóú")
Read More

crystal lang Time strftime

The equivalent for the ruby:

Time.now.strftime("%Y-%m-%d-%H-%M")

is

Time.now.to_s("%Y-%m-%d-%H-%M")
Read More

brew llvm 3.9.0 installation error

Tried to upgrade to llvm 3.9.0, got this error:

[ 40%] Building C object lib/builtins/CMakeFiles/clang_rt.cc_kext_x86_64h_osx.dir/emutls.c.o
[ 40%] Building C object lib/builtins/CMakeFiles/clang_rt.cc_kext_x86_64h_osx.dir/gcc_personality_v0.c.o
[ 40%] Building C object lib/builtins/CMakeFiles/clang_rt.cc_kext_x86_64h_osx.dir/__/profile/InstrProfiling.c.o
[ 40%] Building C object lib/builtins/CMakeFiles/clang_rt.cc_kext_x86_64h_osx.dir/__/profile/InstrProfilingBuffer.c.o
[ 40%] Building C object lib/builtins/CMakeFiles/clang_rt.cc_kext_x86_64h_osx.dir/__/profile/InstrProfilingPlatformDarwin.c.o
[ 40%] Linking C static library libclang_rt.cc_kext_x86_64_osx.a
[ 40%] Built target clang_rt.cc_kext_i386_osx
[ 40%] Building C object lib/builtins/CMakeFiles/clang_rt.cc_kext_x86_64h_osx.dir/__/profile/InstrProfilingWriter.c.o
[ 42%] Linking C static library libclang_rt.cc_kext_x86_64h_osx.a
[ 42%] Built target clang_rt.cc_kext_x86_64_osx
[ 42%] Built target clang_rt.cc_kext_x86_64h_osx
make[3]: *** [all] Error 2
make[2]: *** [tools/clang/runtime/compiler-rt-stamps/compiler-rt-build] Error 2
make[1]: *** [tools/clang/runtime/CMakeFiles/compiler-rt.dir/all] Error 2
make: *** [all] Error 2

Fix was to install it like this:

brew install -s llvm --without-compiler-rt
Read More

crystal http request example

require "http/client"

response   = HTTP::Client.get("https://some.url")

if response.status_code == 200
  # do something with the response
  content    = response.body
end
Read More

python shutil.copyfileobj

Use shutil.copyfileobj instead of having some obj.read(). It will be much better in terms of memory consumption.

Read More