Group Details Private

administrators

Member List
  • Download gutenberg ebooks

    https://www.gutenberg.org/help/mirroring.html

    rsync -av --del aleph.gutenberg.org::gutenberg-epub .
    

    Alternative : download in .zim format

    https://download.kiwix.org/zim/

    posted in Inbox
  • Restore iPad 8 - IPSW
    • iPadOS 17.4.1 (21E237) for iPad 8 (WiFi)
    • Restore IPSW: iPad_10.2_2020_17.4.1_21E237_Restore.ipsw
    • download IPSW from https://ipsw.me/install/iPad11,6/21E237 (7.42GB)
    • Screen displaying: "iPad Unavailable"
    • Enter Restore Mode
      • In "on" state
      • Plug your iPad 8 (WiFi) in to your Mac.
      • Press Power button + Home
      • Hold for exactly 8 seconds, then release Power button while holding Home until apple logo appear and Restore icon displayed
    • While in Restore screen
      • Navigate to your iPad 8 (WiFi) in Finder.
      • Hold the Option or Alt key on your keyboard, and press "Restore".
      • Select the iPad_10.2_2020_17.4.1_21E237_Restore.ipsw file that you downloaded.
      • Wait for the restore to complete, and the iPad 8 (WiFi) to reboot.

    iPhone IPSW: https://www.iclarified.com/750/where-to-download-iphone-firmware-files-from

    posted in Ref
  • Sveltekit init project
    # npm create svelte@latest .
    > skeleton project
    

    Install Tailwind CSS

    # npm install -D tailwindcss postcss autoprefixer
    # npx tailwindcss init -p
    # vim svelte.config.js
    # vim tailwind.config.js
    # vim ./src/app.css
    # vim ./src/routes/+layout.svelte
    

    Add code in svelte.config.js

    import adapter from '@sveltejs/adapter-auto';
    import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
    const config = {
      kit: {
        adapter: adapter()
      },
      preprocess: vitePreprocess()
    };
    export default config;
    

    Edit file: tailwind.config.js

    export default {
      content: ['./src/**/*.{html,js,svelte,ts}'],
      theme: {
        extend: {}
      },
      plugins: []
    };
    

    Modify file ./src/app.css

    @tailwind base;
    @tailwind components;
    @tailwind utilities;
    

    Add Tailwind in +layout.svelte

    <script>
      import "../app.css";
    </script>
    
    <slot />
    

    Sample +page.svelte code

    <div class="text-3xl w-[300px] text-gray-600 bg-white p-10 mx-auto mt-10 shadow-lg rounded text-center">
      Coming soon!
    </div>
    
    <style lang="postcss">:global(html) { background-color: theme(colors.gray.300) }</style>
    

    Push to git (optional)

    # git init && git add -A && git commit -m "Initial commit"
    # git branch -M master
    # git remote add origin [email protected]:project/gitname.git
    # git push -u origin master
    

    Ref: https://tailwindcss.com/docs/guides/sveltekit

    posted in Ref
  • Wordpress - redirect in functions.php
    add_action('template_redirect', 'redirect_old_domain');
    
    function redirect_old_domain() {
        $old_domain = 'domain.org';
        $new_domain = 'domain.com';
    
        if ($_SERVER['HTTP_HOST'] == $old_domain && $request_uri == '/') {
            // Redirect to the new domain without any path
            $redirect_url = 'https://' . $new_domain;
    
            wp_redirect($redirect_url, 302); // 302: Temporary redirect
            exit;
        }
    
        // Check if the request is for a specific year
        preg_match('/\/(\d{4})\//', $request_uri, $matches);
        $year = isset($matches[1]) ? $matches[1] : '';
        
        if ($year) {
            // Redirect to the same URI on the new domain
            $redirect_url = 'https://' . $new_domain . '/' . $year . $request_uri;
        
            wp_redirect($redirect_url, 302); // 302: Temporary redirect
            exit;
        }
    }
    
    posted in Ref
  • Lambda sample function
    console.log('Loading function');
    
    export const handler = async (event, context) => {
    
        //console.log('Received event:', JSON.stringify(event, null, 2));
    
        console.log('value1 =', event.key1);
        console.log('value2 =', event.key2);
        console.log('value3 =', event.key3);
    
        return { message: "hello world", post_body:JSON.stringify(event.body), event: JSON.stringify(event) };  
    };
    
    
    posted in Ref
  • RE: Sveltekit PM2 ecosystem

    NodeJS Build

    npm i -D @sveltejs/adapter-node
    

    File: svelte.config.js

    import adapter from '@sveltejs/adapter-node';
    

    Ref: https://kit.svelte.dev/docs/adapter-node

    posted in Linux
  • Sveltekit PM2 ecosystem

    ecosystem.config.cjs

    module.exports = {
        apps: [
            {
                name: 'name_app',
                script: './build/index.js',
                watch: false,
                // ignore_watch: ['database'],
                autorestart: true,
                env: {
                    PORT: 3000,
                    ENV_PATH: "./.env.local",
                }
            }
        ]
    };
    
    posted in Linux
  • pull.sh script
    cd "/var/www/domain.com/www/source"
    git reset --hard
    git pull
    npm i
    npm run build
    pm2 reload "project_name" 
    
    posted in Linux
  • NextJS 14.0.2 - package.json

    Compatible with Node v21.6.1 (web52)

    {
      "name": "something project name",
      "version": "0.1.0",
      "private": true,
      "scripts": {
        "dev": "next dev",
        "build": "next build",
        "start": "next start -p 3000",
        "lint": "next lint"
      },
      "dependencies": {
        "autoprefixer": "10.4.16",
        "axios": "^1.6.2",
        "dayjs": "^1.11.10",
        "get-youtube-id": "^1.0.1",
        "googleapis": "^128.0.0",
        "md5": "^2.3.0",
        "nanoid": "^5.0.3",
        "next": "14.0.2",
        "next-auth": "^4.24.5",
        "nookies": "^2.5.2",
        "postcss": "8.4.31",
        "react": "18.2.0",
        "react-dom": "18.2.0",
        "react-icons": "^4.12.0",
        "react-lottie": "^1.2.3",
        "react-simple-snackbar": "^1.1.11",
        "react-youtube": "^10.1.0",
        "sweetalert2": "^11.10.0",
        "tailwindcss": "3.3.5",
        "ua-parser-js": "^1.0.37",
        "youtube-player": "^5.6.0"
      },
      "devDependencies": {
        "autoprefixer": "^10.0.1",
        "postcss": "^8",
        "tailwindcss": "^3.3.0"
      }
    }
    
    posted in Linux
  • mongodb backup & restore

    Backup to folder "databasename-DATE"

    mongodump --db databasename --out databasename-$(date +'%m-%d-%y')
    

    Restore

    mongorestore --db databasename --drop databasename-DATE/databasename
    
    mongorestore --db databasename databasename-DATE/databasename
    

    --drop : we’ll make sure that the target database is first dropped so that the backup is restored in a clean database

    Ref: https://www.digitalocean.com/community/tutorials/how-to-back-up-restore-and-migrate-a-mongodb-database-on-ubuntu-20-04

    posted in Linux