Skip to content

Instantly share code, notes, and snippets.

View jtviegas's full-sized avatar

joao tiago viegas jtviegas

View GitHub Profile
#!/bin/bash
# http://bash.cumulonim.biz/NullGlob.html
shopt -s nullglob
# get this file with the following command:
# curl https://gist.githubusercontent.com/jtviegas/35b97994f7a34e5e06ab055f2f47a624/raw/282a0c6628969e5812a70e372ba6636fe0c594ea/helper.sh --output helper.sh
this_folder="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
@jtviegas
jtviegas / commons.inc
Last active December 9, 2021 20:53
bash shell scripts include file with common functionality
# http://bash.cumulonim.biz/NullGlob.html
shopt -s nullglob
verify(){
local _r=0
which kubectl 1>/dev/null
if [ ! "$?" -eq "0" ] ; then err "please install kubectl" && return 1; fi
which az 1>/dev/null
@jtviegas
jtviegas / javaVmOptions.md
Last active August 25, 2020 07:42
java vm options

the vm

get the vm flags

-XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal

check just in time compilation

levels: 1,2,3 (C1 compiler)

level: 4 (C2 compiler => native code) (not on 32 bit vm)

-XX:+PrintCompilation

save compilation log in remote jvm

-XX:+UnlockDiagnosticVMOptions -XX:+LogCompilation

17 Principles of (Unix) Software Design:

  1. Rule of Modularity: Write simple parts connected by clean interfaces.
  2. Rule of Clarity: Clarity is better than cleverness.
  3. Rule of Composition: Design programs to be connected to other programs.
  4. Rule of Separation: Separate policy from mechanism; separate interfaces from engines.
  5. Rule of Simplicity: Design for simplicity; add complexity only where you must.
  6. Rule of Parsimony: Write a big program only when it is clear by demonstration that nothing else will do.
  7. Rule of Transparency: Design for visibility to make inspection and debugging easier.
  8. Rule of Robustness: Robustness is the child of transparency and simplicity.
  9. Rule of Representation: Fold knowledge into data so program logic can be stupid and robust.
@jtviegas
jtviegas / database.md
Last active July 8, 2020 09:54
database.md

ms sql server

blocking queries

SELECT TOP 10 r.session_id, r.plan_handle,      r.sql_handle, r.request_id,      r.start_time, r.status,      r.command, r.database_id,      
r.user_id, r.wait_type,      r.wait_time, r.last_wait_type,      r.wait_resource, r.total_elapsed_time,      r.cpu_time, r.transaction_isolation_level,      
r.row_count, st.text  
FROM sys.dm_exec_requests r  
    CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) as st  
    WHERE r.blocking_session_id = 0       and r.session_id 

Keybase proof

I hereby claim:

  • I am jtviegas on github.
  • I am jtviegas (https://keybase.io/jtviegas) on keybase.
  • I have a public key ASD7R6ci7rKBnaaCP7FiK2A7etJf89As4GoIYxtbo35kAwo

To claim this, I am signing this object:

# necessary git basic config - avoid unnecessary merges
git config pull.rebase true
# Check ports
# To list the TCP ports that are being listened on, and the name of each listener’s daemon and its PID, run the following command:
sudo netstat -plnt
# download a folder from a github project
svn export https://github.com/jtviegas/terraform-modules/trunk/admin admin
### get notebook tokens
> ipython
[1] : system("jupyter" "notebook" "list")
Out[1]:
['Currently running servers:','http://localhost:8895/token=067470c5ddsadc54153ghfjd817d15b5d5f5341e56b0dsad78a :: /u/user/dir']
### istall on untrusted server
<build>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.10.0</version>
<executions>
<execution>
<!-- results in target/pmd.xml and target/site/pmd.html -->
<?xml version="1.0"?>
<ruleset name="Custom Rules"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<description>
custom static analysis rules
</description>