Skip to content

Instantly share code, notes, and snippets.

@Ashkanph
Last active January 20, 2023 09:10
Show Gist options
  • Save Ashkanph/cafaeb128bff4d330c1c1240177be4c5 to your computer and use it in GitHub Desktop.
Save Ashkanph/cafaeb128bff4d330c1c1240177be4c5 to your computer and use it in GitHub Desktop.
all_notes
  • Nuxt state saves to window.__NUXT__.state

  • yarn dev --port 3002 --spa

  • In asyncData: app.i18n.t('tours.slug.error404')

  • yarn config set disable-self-update-check true

  • smbclient //smbaddress -U username -m SMB3

  • Prevent yarn from check for updates: yarn config set disable-self-update-check true

    • You can add this to the .yarnrc too: disable-self-update-check true
  • User's browser and connection information:

    • connection type: navigator.connection.effectiveType
    • Device memory: navigator.deviceMemory
  • The code formatting is available in Visual Studio Code through the following shortcuts:

    • On Windows Shift + Alt + F
    • On Mac Shift + Option + F
    • On Linux Ctrl + Shift + I
  • For search for package in ubuntu

      apt-cache search beautifulsoup
      # I see it has both a 2.7 and 3.3 version in the results. You can get the 3.3 version by installing python3-bs4
      $ sudo apt-get install python3-bs4
  • When installing Go in /usr/local/go: export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin

  • To have standalone dist version of npm libraries: https://unpkg.com/browse/react-custom-scrollbars@4.2.1/dist/

List

Linux, Ubuntu, Arch linux

Google chrome plugins

technologies

Vim

CSS

Bash

React native

Git

Github Repositories

Tools and plugins

links

Libraries

Tutorial

websites

technologies

#Configure npm global directory
mkdir ~/.npm-global # directory where npm will install packages
npm config set prefix '~/.npm-global' # configure npm
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.profile #add directory to path
source ~/.profile # refresh path for current session

# now you can install globally: npm install -g jshint
  • Based on Mozilla website, on Mac, using the tab key for changing the focus is disabled by default for Firefox and Safari. To enable it for testing you can follow the below steps:
    • Firefox for the Mac doesn't do tabbing by default. To turn it on, you have to go to Preferences > Advanced > General, then uncheck "Always use the cursor keys to navigate within pages". Next, you have to open your Mac's System Preferences app, then go to Keyboard > Shortcuts, then select the All Controls radio button.
      • If you weren't able to find that radio button in mac preferences, then instead you can check the option  'Use keyboard navigation to move focus between controls' in your Mac system preferences>keybord>shortcuts. After this reopen Firefox again and you must be able to use the tab key for tabbing
    • Safari doesn't allow you to tab through links by default; to enable this, you need to open Safari's Preferences, go to Advanced, and check the Press Tab to highlight each item on a webpage checkbox.

Google chrome plugins

  • Dark reader
  • Wappalyzer
  • AutoScroll
  • ColorZilla
  • Grid ruler
  • Chrome Audio Capture
  • Make Chrome a text editor: If you enter the follow in URL bar and hit the return key. It will turn Chrome into a notepad: data:text/html, <html contenteditable>
  • To make a website texts editable in chrome: document.designMode='on';

Linux, Ubuntu, Arch linux

  • To see what version of Ubuntu you're using: cat /etc/issue

  • The current git branch: git branch | sed -n -e 's/^\* \(.*\)/\1/p'

  • Own a directory: sudo chown your_username directory

  • My user name: whoami

  • Output a string repeatedly until killed: yes

  • To see partitions: sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL

  • To see partitions with their uuid: sudo blkid

  • Terminating a process on port 8081

    • the process that is listening on port 8081: sudo lsof -i :8081
    • terminate the process kill -9 <PID>
  • Environment set up for Android developing

    • Install OpenJDK 8 in ubuntu: sudo apt-get install openjdk-8-jre
    • In ubuntu it is better to install Android Studio in the /opt directory
  • openconnect

    • sudo apt-get install openconnect
    • sudo openconnect -u username serverAdress
  • To update node:

    sudo npm install n -g
    sudo n lts
  • Get Linux hardware specifications:

    lshw
    lshw -short
    
    # To find motherboard type
    dmidecode | more
    
    lspci
  • To update packages' database in Arch linux: sudo pacman -Sy

  • To fix Manjaro's Persian font, add this file to /home/ashkan/.config/fontconfig/fonts.conf

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
    <match target="pattern">
        <test name="lang" compare="contains">
            <string>fa</string>
        </test>
        <test qual="any" name="family">
            <string>sans-serif</string>
        </test>
        <edit name="family" mode="prepend" binding="strong">
            <string>Noto Sans Arabic</string>
        </edit>
    </match>

    <match target="pattern">
        <test name="lang" compare="contains">
            <string>fa</string>
        </test>
        <test qual="any" name="family">
            <string>serif</string>
        </test>
        <edit name="family" mode="prepend" binding="strong">
            <string>Noto Sans Arabic</string>
        </edit>
    </match>
</fontconfig>
  • Install

    • I needed a swap (about the same size of my RAM memory with the flag of linuxswap).
    • It is better to use different partitions for / (root - 66560 MB) and /home. Then I can easily format the / and my personal files wont change.
    • If you install your dual linux in a separate hard (bios legacy), choose the first hard to install the new linux boot loader (No need to a new separate boot partition for the new linux).
    • Linux uses Grub (2) menu to create boot loader menu
    • GPT (UEFI) vs bios legacy: GPT is modern and new. My laptop didn't support GPT well. For gpt must have /boot/efi (Fat32 - 512MB - with flags: boot, eps, bios-grub).
    • Fast boot boot from the main hard so the usb wont load at boot time.
    • If ubuntu's resolution is not correct
  • Convert some images to a PDF file: sudo convert -auto-orient -quality 65 img1.jpg img2.jpg img3.jpg result.pdf

apps

  • To crop and edit images: Shotwell viewer
  • Cairo clock for ubuntu
    • To create an automatically execute shell script at startup boot
    • Create /etc/systemd/system/my-cairo-clock.service
    [Service]
    ExecStart=/usr/local/bin/disk-space-check.sh
    
    [Install]
    WantedBy=default.target
    • Create /usr/local/bin/initial-cairo-clock.sh
    #!/bin/bash
    cairo-clock
    • sudo chmod 755 /usr/local/bin/initial-cairo-clock.sh
    • systemctl daemon-reload
    • systemctl enable my-cairo-clock.service

vim

  • Save vim as sudo when you have not opened it with sudo: :w !sudo tee %
    • Colon (:) indicates we are in Vim’s ex mode
    • Exclamation (!) mark indicates that we are running shell command
    • sudo and tee are the shell commands
    • Percentage (%) sign indicates all lines from current line

css

 &::before {
       background-repeat: no-repeat;
       content: '';
       position: absolute;
       top: 0;
       left: 0;
       width: 100%;
       height: 100%;
       background-size: 100% 450px;
       background-image: url('~assets/images/tour/partner/wojciech.jpg');
       clip-path: ellipse(100% 55% at 48% 44%);
   }
  • اگر پوزیشین استیکی کار نمی‌کنه معمولا به این دلیله که یه جایی در پرنت‌هاش، آورفلو هایدن شده یا آورفلو ایکس یا ایگرگ.

bash

  • Change some text files with hex data to readble data:
    for f in *.txt; do cat $f | xxd -r -p > ${f}_bin.gz; pigz -d ${f}_bin.gz; done
cat ./selected.txt | xargs -n 3 -I {} echo {}.pdb | xargs cp -t ./selected

React native

  • My problems in opening the app in emulator

    • I updgaded and rebuild the gradle for the project

    • List of all gradle distributions for upgrade

      • I added gradle-6.3-bin.zip to this folder: packages/mobile/android/gradle/wrapper/gradle-6.3-bin.zip
      • And I set the address in the /packages/mobile/android/gradle/wrapper/gradle-wrapper.properties
      • distributionUrl=gradle-6.3-bin.zip
    • I opened the android folder of the project with android studio and tried to run and build it. It installed some stuffs.

    • in the project folder: cd android && ./gradlew clean

  • For using lerna with react-native: I added some lines to metro.config.js

    //metro.config.js
    const path = require('path');
    
    // react-native >= 0.57
    const extraNodeModules = {
       '@myMonoRepo/test1': path.resolve(__dirname + '/../test1/'),
    };
    const watchFolders = [
       path.resolve(__dirname + '/../test1/')
    ];
    
    module.exports = {
      transformer: {
        getTransformOptions: async () => ({
          transform: {
            experimentalImportSupport: false,
            inlineRequires: false,
          },
        }),
      },
      resolver: {
        extraNodeModules,
      },
      watchFolders
    };

git

  • Push the contents of folder build/dist to the gh-page branch of origin remote:
    • git subtree push --prefix build/dist origin gh-pages
  • Push the contents of folder dist to the master branch of remote origin:
    • git push origin `git subtree split --prefix dist dev`:master --force
  • Undo the last commit:
    • git reset --hard HEAD~1
    • git reset --soft HEAD~1
  • I had more than one ssh keys in my ~/.ssh, so I could use this in a project repository: git config core.sshCommand "ssh -i ~/.ssh/id_ed25519_2 -o 'IdentitiesOnly yes'"
    • For using gh-page: GIT_SSH_COMMAND="ssh -i ~/.ssh/id_ed25519_2 -o 'IdentitiesOnly yes'" npm run deploy or GIT_SSH_COMMAND="ssh -i ~/.ssh/id_ed25519_2 -o 'IdentitiesOnly yes'" gh-pages -d public -b master

Github

  • rough-notation
  • screenfull.js - برای اینکه یک عکس یا المنت را تمام‌صفحه کنیم
  • fullpage.js - برای ساخت یک هوم پیج که هر بخشش تمام صفحه باشه
  • canvas-confetti - برای جشن و اینا - کاغذ رنگی که میریزه هوا
  • Dropbox zxcvbn - برای تخمین میزان قدرت یک پسورد
  • Github1s - با گذاشتن یک ۱اس جلوی گیتهاب هر پروژه، می‌توان آن ریپازیتوری را بصورت آنلاین در وی‌اس‌کد دید

tools-plugins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment