My-alpine and docker-compose.yml
MATLAB ... and more ...
by cguitar
11M ago
 ``` version: '1' services:     man:       build: .       image: my-alpine:latest   ```  Dockerfile: ``` FROM alpine:latest ENV PYTHONUNBUFFERED=1 RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python RUN python3 -m ensurepip RUN pip3 install --no-cache --upgrade pip setuptools RUN apk add git ..read more
Visit website
A Kotlin recursive function
MATLAB ... and more ...
by cguitar
1y ago
 import kotlin.reflect.full.memberProperties data class Abc(     val a: String,     val b: String,     val c: String,     val d: D,     val e: E ) {     data class D(         val e: String,         val f: String,         val g: String     )     data class E(         val h: List<String>     ) } data class Xyz(     val a: String,     val b: String,     val c: String,     val d ..read more
Visit website
A nice alias to check the resources used be each user on a Linux server
MATLAB ... and more ...
by cguitar
1y ago
 Sometimes on a shared Linux server or AWS EC2, we found out the resources are limited because some other persons are using the machine, and we want to rank order the users by resources used from high to low. This alias does exactly this. ``` alias wtf="ps hax -o rss,user | awk '{a[\$2]+=\$1;}END{for(i in a)print i\"  \"int(a[i]/1024+0.5);}' | sort -rnk2 ..read more
Visit website
AWK: count which customer has the most unique accounts
MATLAB ... and more ...
by cguitar
2y ago
Content of the count_uniq.awk script: BEGIN {     FS=","; } {     if ($0 in seen == 0){arr[$2]++} else {seen[$0]=1}     seen[$0]=1; } END {     for (a in arr) print a, arr[a] } What it does? count how many accounts does each customer has, ignoring duplicated rows. Details as in image below: Customer "a" has 3 different accounts: [1, 2, 3] Customer "b" has 1 account: [2] Customer "c" has 2 accounts: [1, 2 ..read more
Visit website
Concatenate multiple files with same headers (and only keep one header line in the output file) - Version2
MATLAB ... and more ...
by cguitar
2y ago
 Put this into an AWK script and call it merge.awk: BEGIN{     h=ARGV[1];     ARGV[1]=""; } {     if(FNR==1){print}     else if($1!~h){print} } and use an argument: cat *.csv | awk -f merge.awk "<header>" > output.csv ..read more
Visit website
Git: find string in a certain branch
MATLAB ... and more ...
by cguitar
2y ago
 So, today I cloned a repo and it has many branches. I know one of the branches has a file that is updated and contains the word "token". This is how I find out which branch it is: git branch -a | cut -c3- | cut -d' ' -f 1 | xargs git grep "token"  ..read more
Visit website
Cron.allow
MATLAB ... and more ...
by cguitar
2y ago
If a user on Linux can't run "crontab -l" or "corntab -e", add the user name to /etc/cron.allow, and then it should work.  ..read more
Visit website
WOE
MATLAB ... and more ...
by cguitar
2y ago
 #http://lazynight.me/4048.html import mathimport numpy as npfrom scipy import statsfrom sklearn.utils.multiclass import type_of_targetclass WOE(object):def __init__(self):self._WOE_MIN = -20self._WOE_MAX = 20def processing(self, X, y, event=1):self.check_target_binary(y)X1 = self.feature_discretion(X)res_woe = []res_iv = []for i in range(0, X1.shape[-1]):x = X1[:, i]woe_dict, iv1 = self.woe_single_x(x, y, event)res_woe.append(woe_dict)res_iv.append(iv1)return np.array(res_woe), np.array(res_iv)def woe_single_x(self, x, y, event=1):self.check_target_binary(y)event_total, non_event_total ..read more
Visit website
Street suffix abbreviations
MATLAB ... and more ...
by cguitar
2y ago
# Street suffix abbreviations  # https://pe.usps.com/text/pub28/28apc_002.htm addressStandardMap = {'ALLEE': 'ALLEY',                       'ALLY' : 'ALLEY',                       'ALY':   'ALLEY',                       'ANEX':  'ANNEX',                       'ANNX':  'ANNEX',                       ..read more
Visit website
Some bash alias I found very useful
MATLAB ... and more ...
by cguitar
2y ago
 # User specific aliases and functions alias showheader='head -1|tr "," "\n" | tr "|" "\n" |tr "^" "\n" |  nl -ba | less' alias pnfc='awk -F"," "{print NF}"' alias pnfp='awk -F"|" "{print NF}"' alias mytop='top -u <username>' alias cl='clear' alias head5='head -5' alias head2='head -2' alias head1='head -1' alias lsht='ls -lsh --sort=time' alias lshs='ls -lsh --sort=size' alias savehist='history | tail -2 | head -1 >> NOTES' alias x='chmod +x' alias ssactivate='source activate <env name>' alias cls='clear' alias lsl='ls -alh --color=auto' alias du='du -h' alias df ..read more
Visit website

Follow MATLAB ... and more ... on FeedSpot

Continue with Google
Continue with Apple
OR