GithubHelp home page GithubHelp logo

blekmus / archive Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 9.87 MB

A techy knowledge base for the easily forgetful

Home Page: https://archive.dinil.dev

TypeScript 8.46% CSS 5.05% JavaScript 0.79% MDX 85.71%
knowledge-base linux docs nextra

archive's Introduction

Helloo

What is this?

This is basically my unix and everything techy knowledge base. I made this to help lessen the blow from my lousy memory retention abilities.

The site is hosted on Github Pages and is built using Nextra with a few custom react components scattered here and there.

archive's People

Contributors

blekmus avatar caidenwilson avatar

Watchers

 avatar

archive's Issues

SQL alter column type

First go into the database;
use dbname;

Then to alter it's type;
alter table tablename modify column columname type;

This doesn't fuck up the data unless the new type isn't compatible with the old one. Also make sure to make a backup before hand.

Networking

netstat -ltnp | grep -w ':80'
specific port usage

sudo netstat -tlpn
all port usage

detialed info about pid
ps -Flww -p THE_ID

Fonts

to add a new font put it in /usr/share/fonts/

find more info...

javascript lang

const o = {
  fn: function () {

  }
};

const o = {
  fn: () => {

  }
};

const o = {
  fn () {

  }
};

All three are equal in creating o.fn

Fucking UFW SSH port

Replace that damn thing with a random variable for all I care. Just replace it. Can't believe, I'm being this aggressive towards myself.

additions

systemd group new command

create new group in #groups

Ghost nginx

by default the port is set to 2369 but in truth it's 2368

nginx www to non www

First create A records from both the domain's root and www subdomain towards the server. Then create the usual nginx conf. But under that conf add this block also

server {
server_name www.example.com;
return 301 $scheme://example.com$request_uri;
}

Flask layered approach

This is great for logging. You get a clear picture as to what went wrong where.

The outer layer - Nginx
The middle layer - gunicorn/WSGI
The inner layer - app script

Remove nav in the yaml config

This should probably tell mkdocs to auto generate the pages instead of having to specifying all of them. Also check out docs_dir config option

php docs page formatting needed

The switching active version shouldn't be a whole header. It should be under version mayhem.

Then there's some grammatical errors in the plugins section

Mailgun bulk emails to mailing list using template

import requests

def batch_mailing():
    req = requests.post(
        "https://api.{eu}.mailgun.net/v3/{domain}/messages",
        auth=("api", "{domain-api-key}"),
        data = {
            "from": "{from display name}",
            "to": "{mailing list name}",
            "subject": " {mail subject}",
            "template": "{domain template name}"
    )
    
    return req


response = batch_mailing()
print(response.text)

get rid of the eu if the domain is based on another country

401 files too large

Not 401 it's 413

There are two causes for this.

  1. The web server limits it
  2. PHP limits it

For web server limitations

###Apache.
Incease the LimitRequestBody
It can be used in any virtualhost or location directive. Check here for more info. Here you need to convert whatever rerquest size you need into bytes. Use this to convert

<Directory "/var/www/site">
	LimitRequestBody  5242880
</Directory>

Then remeber to restart apache using

sudo service apache2 reload

Nginx.

This is easy. Just edit

sudo nano /etc/nginx/nginx.conf

Then change this to whatever size you want

client_max_body_size 2M;

Again remember to reload nginx using

sudo service nginx reload

Now for php

FIrst find what php config file your running. Now the thing to remember here is if your running both apache and nginx at the same time. There's a possibility that the two are using different php.ini's so you'll need to change both of them.

First create a php-test file at /var/www/php-test. Find how here <-- link to php page with a test file example

To find which config apache is reading from. Create a new conf file at /etc/apache2/sites-available and point it towards the php-test folder at /var/www
Remember if your using nginx to route apache traffic. You'll need to customize the apache config in /etc/nginx as well, with the domain you put in side of the apache config file.

To find which is read in nginx create a config file at /etc/nginx with the usual php config. Then point it towards the php-test folder.

The config file that's read by php should be plain obvious in the info page. So now to edit the config file

In the .ini file's there two need to be changed

upload_max_filesize = 100M
post_max_size = 100M

change them to whatever size you see if. Again restart the services handling php

sudo service apache2 restart
sudo service nginx restart
sudo service phpx.x-fpm restart

That's it. This should most probably solve the issue

Servname not supported for ai_socktype and ntp

With the following rules-set, NTP-synchronization is working perfectly for me:

sudo ufw allow 123/udp
sudo ufw allow out 123/udp
sudo ufw allow out 53

I've allowed UDP port 123 for both incoming and outgoing traffic to NTP work. Additionally I also needed to open TCP port 53 (DNS) for outgoing traffic since /etc/ntp.conf contains domain names of NTP servers. .

umount: device is busy. Why?

Working directory or (possibly deleted) file open of a running process

# umount /mnt/test
umount: /mnt/test: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
# lsof /mnt/test/
COMMAND   PID  USER   FD   TYPE DEVICE SIZE/OFF  NODE NAME
bash    10934 tange  cwd    DIR    7,0     4096 65537 /mnt/test/testdir
cat     14286 tange    1w   REG    7,0        0 65538 /mnt/test/testdir/a
cat     14291 tange    1w   REG    7,0        2 65539 /mnt/test/testdir/b (deleted)
# kill -9 10934 14286 14291
# lsof /mnt/test/
# umount /mnt/test

Open (possibly deleted) socket

# umount /mnt/test
umount: /mnt/test: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
# lsof -a | grep /mnt/test/
tmux  14378  tange  6u  unix 0xacf703c0  0t0  656531 /mnt/test/tmux-1000/default type=STREAM
# kill 14378
# lsof -a | grep /mnt/test/ 
# umount /mnt/test

nfs-kernel-server is exporting the directory (and the directory is mounted by a client)

# umount /mnt/test
umount: /mnt/test: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
# showmount -e
Export list for alpha:
/mnt/test 192.168.1.203
# /etc/init.d/nfs-kernel-server stop
# umount /mnt/test

A loopback device backing file exists in the dir

# umount /mnt/test
umount: /mnt/test: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
# losetup -a
/dev/loop0: [0851]:6983 (/mnt/test/testdir/disk.img)
/dev/loop1: [0851]:6986 (/mnt/test/testdir/disk2.img)
# umount /mnt/test/testdir/disk.img
# umount /mnt/test/testdir/disk2.img
umount: /mnt/test/testdir/disk2.img: not mounted
# losetup -d /dev/loop1
# umount /mnt/test

A swapfile exists in the dir

# umount /mnt/test
umount: /mnt/test: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
# cat /proc/swaps
Filename                                Type            Size    Used    Priority
/mnt/test/testdir/swapfile              file            95480   0       -2
# swapoff /mnt/test/testdir/swapfile
# umount /mnt/test

The device failed

# umount /mnt/test
umount: /mnt/test: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1)) 

# dmesg

:

[75620.618404] lost page write due to I/O error on md0
[75620.618408] Buffer I/O error on device md0, logical block 16804
:

[75890.015507] INFO: task cp:27736 blocked for more than 120 seconds.
[75890.015513] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[75890.015516] cp              D ffff88053fdd39c0     0 27736  27734 0x00000004
## Here I have not found a solution, so:
# umount -l /mnt/test

The dir contains an umounted encfs

normaluser$ encfs /mnt/test/dir.enc /mnt/test/dir
EncFS Password:
# umount /mnt/test/dir
# umount /mnt/test
umount: /mnt/test: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
## Here I have not found a solution, so:
# umount -l /mnt/test

database

# delete user
DROP USER '<user-name>'@localhost;

# drop database
DROP DATABASE <db-name>

Database backup

Two types of backups

  1. Logical Backup
  2. Physical Backup

Physical
This is basically copying the base sql dir after stopping sql.

Logical
mysqldump --all-databases > /backup/mariadb.dump
mysqldump dbname > /backup/inventory.dump

first create the database in mysql then import the tables and data
mysql dbname < /backup/mariadb.dump

Disable top bar retract

This is causing a page error in mobile view.

If there's a page that's a bit long. If your scrolling down, at a point the top bar automatically retracts. At that moment you can zoom the page out. The already existing layout stays the same but on the right there's an infinite void you can scroll to horizontally.

But guess what. If you just scroll up a bit. Over an unknown but stationary cutoff point, the top bar comes down again. When this happens the void suddenly disappears and the site is good as new.

networking info

$ curl -is http://127.0.0.1:3000/

X-Powered-By: Express
Vary: Origin
Access-Control-Allow-Credentials: true
Content-Type: text/html; charset=utf-8
Content-Length: 6
ETag: W/"6-j32I6QGlrToF2MwN6TMT/XYCj4w"
Date: Fri, 26 Jan 2018 18:58:27 GMT
Connection: keep-alive```

batch csv to google contacts

import csv

numlist = []

with open('math.csv', mode='r') as file:
    csv_reader = csv.DictReader(file)

    for row in csv_reader:
        numlist.append(row['first'])

filtred = set(numlist)

formatted = {}
for x, num in enumerate(filtred):
    item = x % 256
    base = x // 256

    formatted[f'CM{base:02d}-{item:03d}'] = num


with open('new_math.csv', mode='w') as file:

    fieldnames = [
        'Name',
        'Given Name',
        'Additional Name',
        'Family Name',
        'Yomi Name',
        'Given Name Yomi',
        'Additional Name Yomi',
        'Family Name Yomi',
        'Name Prefix',
        'Name Suffix',
        'Initials',
        'Nickname',
        'Short Name',
        'Maiden Name',
        'Birthday',
        'Gender',
        'Location',
        'Billing Information',
        'Directory Server',
        'Mileage',
        'Occupation',
        'Hobby',
        'Sensitivity',
        'Priority',
        'Subject',
        'Notes',
        'Language',
        'Photo',
        'Group Membership',
        'Phone 1 - Type',
        'Phone 1 - Value'
    ]


    writer = csv.DictWriter(file, fieldnames=fieldnames)
    writer.writeheader()

    for x, y in formatted.items():
        writer.writerow({'Phone 1 - Value': y, 'Name': x})

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.