Skip to content

Instantly share code, notes, and snippets.

@madsonic
madsonic / filter.swift
Last active April 10, 2017 22:38
filtering QBChatDialog
let page = QBResponsePage(limit: 100)
let extendedRequest = ["occupant_ids": "[25976759, 26025952]"]
QBRequest.dialogs(for: page, extendedRequest: extendedRequest, successBlock: { (response: QBResponse, dialogs: [QBChatDialog]?, dialogsUsersIDs: Set<NSNumber>?, page: QBResponsePage?) -> Void in
print(dialogsUsersIDs)
}) { (errResponse: QBResponse) -> Void in
print("error")
print(errResponse)
}
@madsonic
madsonic / Aggregation.java
Created September 14, 2017 13:24
Association, dependency, composition and aggregation
public class Aggregation {
Foo foo;
public Aggregation(Foo foo) {
this.foo = foo;
}
}
@madsonic
madsonic / split bug
Created March 30, 2018 09:30
unable to split small1.txt but even though it exist. cat small1.txt works though
/Users/Gerald/github/you-shell-fail/mytest>ls
a
a b.txt
abyss.txt
bar/
large1.txt
large2.txt
large3.txt
medium1.txt
medium2.txt
@madsonic
madsonic / kube-docker-onetime
Last active April 17, 2020 04:52
Cheat sheet related to k8/docker/helm and other related technologies
# long
docker run --rm -ti \
--publish <container port>:<exposed port> \
--env <env>=<val> \
--volume <local path>:<mounted path> \
<repo>/<image>:<tag>
# short
docker run --rm -ti \
-p <container port>:<exposed port> \
{{- /*
The standard labels are frequently used in metadata.
*/ -}}
{{- define "yourchart.labels.standard" -}}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
helm.sh/chart: {{ include "yourchart.chart" . }}
helm.sh/appVersion: {{ .Chart.AppVersion | quote }}
helm.sh/chartVersion: {{ .Chart.Version | quote }}
helm.sh/revision: {{ .Chart.Revision | quote }}
@madsonic
madsonic / TLS-check
Last active April 18, 2019 02:31
commands for checking TLS certs
# CAfile trusts a given CA cert for this call
# should return 0
# Certificate chain is presented:
# Number on left represents depth
# example.com is the first subject i.e. the host we are contacting
# and its issuer is Fake LE Intermediate X1
# the next cert on the chain has its subject as Fake LE Intermediate X1
# and its issuer is Fake LE Root X1
# which is the root of the chain i.e. a Certificate Authority
#
@madsonic
madsonic / sshconfig
Last active January 21, 2020 15:31
useful ssh configurations
Host *
ControlMaster auto
ControlPath ~/.ssh/sockets/%C
ControlPersist 120
IdentityFile ~/.ssh/id_rsa
Host *
ControlMaster auto
ControlPath ~/.ssh/sockets/%C
ControlPersist 120
@madsonic
madsonic / gatherfacts
Last active May 24, 2019 09:51
ansible gather facts
# stdout_call back must be in json
ansible -i <inventory> <inventory_hostname> -m setup
# depending on ansible config, the facts file might be cached locally, see '~/ansible.cfg'
# internal ip
"{{ ansible_facts['default_ipv4']['address'] }}"
@madsonic
madsonic / mount empty volume
Last active December 2, 2019 03:17
volume modification
# see existing filesystem
# if no fs, 'data' will be shown
sudo file -s /dev/xvdf
# make fs
mkfs.ext4 /dev/sdb
mkdir /mnt/a
# mount it onto a directory
@madsonic
madsonic / grep
Created June 25, 2019 03:13
grep
# search for pattern in given path
# -r recursive
# -n line number
# -H print file name
# -I ignore binary
grep -rnHI '<regex>' <file/dir>