54 notes

about 1 month ago
wget from index of page

wget -c -m -nH --no-parent --reject "index.html*" <Directory URL>

3 months ago
Generate new key pair with RSA 4096

gpg --full-gen-key

List private keys

gpg --list-secret-keys --keyid-format LONG

Liste public keys

gpg --list-keys --keyid-format LONG

Delete private key

gpg --delete-secret-keys

Delete public key

gpg --delete-keys

Export public key

gpg --armor --export <key-id> > pub.key

Import keys

gpg --import my-private-key.asc

Decrypt msg

gpg -d msg.txt
7 months ago
Setup UTF-8 environment in Linux

# check env - wrong setting

locale -a
> locale: Cannot set LC_CTYPE to default locale: No such file or directory

echo "$LC_CTYPE"
> UTF-8

# right setting

export LC_CTYPE="en_US.UTF-8"

echo "$LC_CTYPE"
> en_US.UTF-8

# add to bash

export LC_CTYPE="en_US.UTF-8"

vi ~/.bashrc

9 months ago

Show running #docker containers
$ docker ps -a

Build container
$ docker build -t pyspark3:latest -f Dockerfile .

Create container from image
$ docker run -it -v $(pwd):/opt/doc/working_dir -p 8888:8888 --name work pyspark3

Start container 
$ docker start -ai work

Stop container
$ docker stop work

Kill container if port is not released

$ docker stop $(docker ps -a -q); docker rm $(docker ps -a -q);

9 months ago
Kubernetes v1.10.11 Dashboard login

create token

$ kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')

copy token, start cluster

$ kubectl proxy

open url


9 months ago
ssh-copy-id btw linux servers

ssh -i ~/.ssh/mykey user@host

if still asking for password

ssh-agent bash
ssh-add ~/.ssh/id_rsa
Enter passphrase for /home/user/.ssh/id_rsa: # ENTER YOUR PASSWORD
Identity added: /home/user/.ssh/id_rsa (/home/u/.ssh/id_rsa)
9 months ago
Git sign commits with PGP key

gpg --list-secret-keys --keyid-format LONG <email>

sec   rsa4096/<key-id> [SC]

git config --global user.signingkey <key-id>

Sign every commit 

git config --global commit.gpgsign true

Check name and email

git config --global user.email <email>
git config --global user.name <name>

9 months ago

CONNECT TO DB --> \c dbname


# Start console

CREATE USER username WITH PASSWORD 'password';
ALTER DATABASE owncloud OWNER TO username;

psql -U user -h database

sudo su postgres
$ psql 

# Then lets setup `role` and create database for owncloud 

postgres=# CREATE ROLE owncloud ; 
postgres=# ALTER ROLE owncloud WITH PASSWORD 'myPassword' ;
postgres=# ALTER ROLE owncloud WITH LOGIN ;

postgres=# CREATE DATABASE owncloud ;
postgres=# ALTER DATABASE owncloud OWNER TO owncloud ;

postgres=# \list
postgres=# \q 

# Data directory

SHOW data_directory;
9 months ago
Linux transfer data to webservices


The easiest way to make the config is to run rclone with the config option:

rclone config


rclone ls remote:path # lists a re
rclone copy /local/path remote:path # copies /local/path to the remote
rclone sync /local/path remote:path # syncs /local/path to the remote

9 months ago
So one day Jeff Bezos issued a mandate.  He's doing that all the time, of course, and people scramble like ants being pounded with a rubber mallet whenever it happens. But on one occasion -- back around 2002 I think, plus or minus a year -- he issued a mandate that was so out there, so huge and eye-bulgingly ponderous, that it made all of his other mandates look like unsolicited peer bonuses.

His Big Mandate went something along these lines:

  1) All teams will henceforth expose their data and functionality through service interfaces.

  2) Teams must communicate with each other through these interfaces.

  3) There will be no other form of interprocess communication allowed:  no direct linking, no direct reads of another team's data store, no shared-memory model, no back-doors whatsoever.  The only communication allowed is via service interface calls over the network.

  4) It doesn't matter what technology they use.  HTTP, Corba, Pubsub, custom protocols -- doesn't matter.  Bezos doesn't care.

  5) All service interfaces, without exception, must be designed from the ground up to be externalizable.  That is to say, the team must plan and design to be able to expose the interface to developers in the outside world.  No exceptions.

  6) Anyone who doesn't do this will be fired.

  7) Thank you; have a nice day!

Ha, ha!  You 150-odd ex-Am...
9 months ago

Are your lights on?

A Problem is a difference between things as desired and things as perceived.

Perception: The kids are too noisy. Desire: Quiet children.

Phantom problems are read problems.

Don't bother trying to solve problems for people who don't have a sense of humor.

> What is the problem?

Don't take their solution method for a problem definition.

If you solve their problem too readily, they'll never believe you've solved their real problem.

You can never be sure you have a correct definition, even after the problem is solved.

Don't leap to conclusions, but don't ignore your first impression.

You can never be sure you have a correct definition, but don't ever stop trying to get one.

> What is the problem really?

Each solution is the source of the next problem.

The trickiest part of certain problems is just recognizing their existence.

If you can't think of at least three things that might be wrong with your understanding of the problem, you don't understand the problem.

Test you definition on a foreign, someone blind, or a child, or make yourself foreign, blind, or childlike.

Each new point of view will produce a new misfit.

How could we change the problem statement to make the solution different?

Once you have a problem statement in words, play with the words until the statement is in everyones head.

> Whose problem...
9 months ago
The only real competitive advantage is that which cannot be copied and cannot be bought.
about 1 year ago
#rbenv #ruby #update

cd ~/.rbenv/plugins/ruby-build
git pull

cd ~/.rbenv
git pull

show available verions
rbenv install --list

install new ruby version
rbenv install 2.5.3
rbenv global 2.5.3

new bundler
gem install bundler

about 1 year ago
Mastodon commands

Show log
$ journalctl -xf -u mastodon-*

Start instance
$ systemctl start mastodon-*.service

Stop instance
$ systemctl stop mastodon-*.service

Status of instance
$ systemctl status mastodon-*.service

Enter rails console
$ RAILS_ENV=production bundle exec rails c

Switch to mastadon user
$ sudo su - mastodon

Enter postgres
$ psql

Show databases
=> \l

Quit postgres
=> \q

Backup postgres
sudo -u postgres pg_dump mastodon_production > mastodon_production.sql

about 1 year ago
#diaspora pod update

rvm get latest

if needed

git checkout upstream/master Gemfile.lock
git checkout upstream/master db/schema.rb

update from repo

git pull
cd .. && cd -

update bundler and gems

gem install bundler
RAILS_ENV=production bin/bundle; bin/bundle clean
migrate db schema

RAILS_ENV=production bin/rake db:migrate

compile assets

RAILS_ENV=production bin/rake assets:precompile 
RAILS_ENV=production bin/rake assets:clean


bin/eye restart web 
bin/eye restart sidekiq
about 1 year ago
force unmount on #linux

fuser -kim /dev/sdd1

then unmount

umount /dev/sdd1

over 1 year ago
It's about meaning not money

Make meaning
Anticipate needs
Jump to the next curve
Let 100 followers blosson
Nice thyself
Unique + value, to right corner
Churn baby churn
Make big challenges
Change your mind
Don't let the bozos grind you down

over 1 year ago
When you're 90% done... you still have 90% to go

In other words you need to 10x
over 1 year ago
Install redis on Mac
$ brew install redis

Start redis
$ redis-server /usr/local/etc/redis.conf

Config file
$ cat /usr/local/etc/redis.conf

Test if redis is running
$ redis-cli ping

over 1 year ago
Git checkout the latest tagged version

$ git tag -l

$ git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)

over 1 year ago
Reduce your server's resource usage by moving #MySQL temporary directory to tmpfs for better #performance


over 1 year ago

Traction Thinking

Spend 50% of your time on product and 50% on traction.


It helps you build the right product.
  • get feedback from early customers
  • what features are missing
  • which part of the experience are broken

You can think of your initial investment in traction as pouring water into leaky bucket. At first your bucket will be very leaky because your product is not yet a full solution to customer needs and problems. In other words, your product is not as sticky as it could be, and many customers will not want to engage with it yet. As a consequence, much of the money your are spending on traction will leak out of your bucket. If you don't interact with cold customers in this way, then you generally spend time on the wrong things in terms of product development.

Test different traction channels before you launch anything.

over 1 year ago
Show installed python packages

pip list

Install a new python package

pip install package_name

Mac OSX upgrade package

pip install --user --upgrade matplotlib

over 1 year ago
“everything in the world was created by people no smarter than you”. You can do whatever you want, once you realize one secret: everything big starts small. -Steve Jobs 

over 1 year ago
How to copy files from one server to another using #ssh on #linux

scp <source> <destination>

To copy a file from B to A while logged into B:
scp /path/to/file username@a:/path/to/destination

To copy a file from B to A while logged into A:
scp username@b:/path/to/file /path/to/destination

over 1 year ago
You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.

vi .bundle/config

change the BUNDLE_FROZEN


again "bundle install"

#bundler #ruby 

over 1 year ago
Show physical CPUs on #mac

$ sysctl -n hw.physicalcpu

Logical CPUs

$ sysctl -n hw.logicalcpu

over 1 year ago
Install redis on macOS

$ brew install redis

Start redis-server

$ brew services start redis

Test if Redis server is running

$ redis-cli ping

If it replies “PONG”, then it’s good to go!

#mac #redis #brew

over 1 year ago

OS X Screencast to animated GIF

To capture the video, using the free "QuickTime Player" application:

  • Open "Quicktime Player",
  • Go to File -> New Screen Recording
  • Selected screen portion by dragging a rectangle, recorded 13 second video.
  • Go to File -> Export -> As Movie
    • Saved the video in full quality with the filename in.mov
To convert in.mov into out.gif, open Terminal to the folder with in.mov and run the following command:

ffmpeg -i in.mov -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > out.gif

Notes on the arguments:

  • -r 10 tells ffmpeg to reduce the frame rate from 25 fps to 10
  • -s 600x400 tells ffmpeg the max-width and max-height
  • --delay=3 tells gifsicle to delay 30ms between each gif
  • --optimize=3 requests that gifsicle use the slowest/most file-size optimization

The conversion process requires the following command-line tools:

  • ffmpeg to process the video file
  • gifsicle to create and optimize the an animated gif
If you use homebrew and homebrew-cask software packages, just type this in:

brew install ffmpeg 
brew cask install x-quartz #dependency for gif...
over 1 year ago

Let's encrypt a 100 MB file using the latest browser - WebCrypto API Speed Test 

How long does it take to encrypt a file using the WebCrypto API on the latest browsers? We measured the speed on Firefox, Chrome, Safari, Opera, and IE11 does support Web Cryptography, but that's based on an old version of the spec. https://caniuse.com/#feat=cryptography

The W3C Recommendation from 26 January 2017 describes a JavaScript API for performing basic cryptographic operations in web applications, such as hashing, signature generation and verification, and encryption and decryption. https://www.w3.org/TR/WebCryptoAPI/

Test setup: 2,4 GHz Intel Core i5, 16 GB 1333 MHz DDR3, Intel HD 3000 512 MB, running macOS Sierra v10.12.6.
JavaScript encryption library: OpenPGP.js v3.0.3 https://github.com/openpgpjs/openpgpjs

And the winner is Firefox 59!

25 MB -> 3.0 seconds
50 MB -> 5.8 seconds
100 MB -> 14.2 seconds

2. Safari 11

25 MB -> 4.2 seconds
50 MB -> 7.3 seconds
100 MB -> timeout

3. Chrome 65

25 MB -> 10.0 seconds
50 MB -> 19.1 seconds
100 MB -> timeout

4. Opera 52
over 1 year ago
#rvm #ruby 

If you want create the .ruby-version and .ruby-gemset file in a short way you can use the commands like this:

rvm use 2.3.3@appname --create

rvm --create --ruby-version 2.3.3@appname

over 1 year ago
Create new user in #mysql and grant privileges

> CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';


> GRANT ALL PRIVILEGES ON db_name.* TO 'username'@'localhost' IDENTIFIED BY 'password';
over 1 year ago
#Rails #mysql2 gem compatibility

  • mysql2 0.4.x works with Rails / Active Record 4.2.5 - 5.0 and higher.
  • mysql2 0.3.x works with Rails / Active Record 3.1, 3.2, 4.x, 5.0.
  • mysql2 0.2.x works with Rails / Active Record 2.3 - 3.0.
over 1 year ago
#openpgpjs / https://github.com/openpgpjs / version 2.0

Load public key

> var pubkey = "-----BEGIN PGP PUBLIC KEY BLOCK----- ... "
> openpgp.key.readArmored(pubkey)

Get all primary keys

> openpgp.key.readArmored(pubkey).keys

Get expiration time of primary key

> openpgp.key.readArmored(pubkey).keys[0].getExpirationTime()

Get all sub keys

> openpgp.key.readArmored(pubkey).keys[0].subKeys

Get expiration time of a sub key

> openpgp.key.readArmored(pubkey).keys[0].subKeys[0].getExpirationTime()

Check if primary key is valid

> openpgp.key.readArmored(pubkey).keys[0].verifyPrimaryKey()

Check if sub key is valid

> openpgp.key.readArmored(pubkey).keys[0].subKeys[0].verify(openpgp.key.readArmored(pubkey).keys[0].primaryKey)

Key status

> openpgp.enums.keyStatus

Object {invalid: 0, expired: 1, revoked: 2, valid: 3, no_self_cert: 4}

over 1 year ago
See what rules are already configured
iptables -L
Edit iptables
Activate these new rules
iptables-restore < /etc/iptables.test.rules
Check the diff 
iptables -L
Save the new rules to the master iptables file
iptables-save > /etc/iptables.up.rules

#debian #iptables

Syntax to block an IP address under Linux

iptables -A INPUT -s IP-ADDRESS -j DROP

almost 2 years ago
Full unicode support in #mysql 

For each database:
ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;

For each table:
ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

For each column:
ALTER TABLE table_name CHANGE column_name column_name VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Database config in #rails

  # ...
  encoding: utf8mb4
  collation: utf8mb4_bin
almost 2 years ago
Show #python version in #zeppelin in #pyspark


import sys

Show #spark version


almost 2 years ago
check RTP record / #dns

$ dig -x ip-address

almost 2 years ago
test #sendmail

% echo "test message" | sendmail -v reciver@me.com
almost 2 years ago
List files in #HDFS

$ hdfs dfs -ls /

List dfs report

$ hdfs dfsadmin -report