Trik Unduh Live Streaming

Unduh file yang ada audionya menggunakan situs pengunduh online. Misalkan berinama Mov_Audio.mp4 atau yang lainnya.

Unduh file yang beresolusi paling tinggi menggunkan situs pengunduh, biasanya ini hanya dapat mengunduh videonya saja. Tidak masalah, misalkan berinama Mov_HD.mp4

Pastikan ffmpeg sudah terapsang lalu berikan perintah:

ffmpeg -i Mov_HD.mp4 -i Mov_Audio.mp4 -map 0:v:0 -map 1:a:0 -c copy -shortest -movflags +faststart Mov_HD_Audio.mp4

Keterangan:

OpsiFungsi
-iTambah input
-mapPilih stream tertentu, misal file ke 0: video: stream 0
-map 0:v:0
Pilih stream tertentu, misal file ke 1: audio: stream 0
-map 1:a:0
-c copyTanpa re-encode
-shortestSinkron audio-video, Output akan berhenti saat stream terpendek selesai
-movflags +faststartMP4 editor-friendly

AI Comparison

ModelRole/NicknameStrengthsBest Use Cases
GPT‑4oThe GeneralistFast, multimodal (text, image, audio)Brainstorming, casual chats, mixed-media inputs
GPT‑03The ProfessorIn-depth analysis, well-sourced responsesAcademic/legal research, complex scenarios
GPT‑4.5The WordsmithCreative writing, vivid languageStorytelling, marketing copy, polished prose
GPT‑4.1The CoderCoding assistance, handles long transcriptsDev workflows, code reviews, technical documentation
o4‑mini / o4‑mini‑highBudget/Task‑SpecificFast, cost-efficient, accurate for specific tasksBulk classification, light logic puzzles, targeted querying
GPT‑03 ProThe OracleDeep reasoning, highly analyticalCritical decision‑making, detailed research tasks

Create Graph from Text 2

C++ code

#include <iostream>
using namespace std;

int main() {
    int number;

    // Input from user
    cout << "Masukkan sebuah bilangan: ";
    cin >> number;

    // Check positive, negative, or zero
    if (number > 0) {
        cout << number << " adalah bilangan positif." << endl;
    } else if (number < 0) {
        cout << number << " adalah bilangan negatif." << endl;
    } else {
        cout << number << " adalah nol." << endl;
    }

    // Check odd or even
    if (number % 2 == 0) {
        cout << number << " adalah bilangan genap." << endl;
    } else {
        cout << number << " adalah bilangan ganjil." << endl;
    }

    return 0;
}

eraser.io syntax

KlasifikasiBilangan {
  mulai[shape:oval]
  masukkan bilangan[shape:parallelogram]
  cek apakah bilangan GE 0 [shape:diamond]
  cek apakah bilangan EQ 0 [shape:diamond]
  cetak nol [shape:parallelogram]
  cetak positif [shape:parallelogram]
  cetak negatif [shape:parallelogram]
  cek apakah bilangan mod 2 EQ 0 [shape:diamond]
  cetak genap [shape:parallelogram]
  cetak ganjil [shape:parallelogram]
  selesai[shape:oval]
}

mulai>masukkan bilangan>cek apakah bilangan GE 0
cek apakah bilangan GE 0>cek apakah bilangan EQ 0:ya
cek apakah bilangan EQ 0>cetak nol:ya
cek apakah bilangan EQ 0>cetak positif:tidak
cek apakah bilangan GE 0>cetak negatif:tidak
cetak nol>cek apakah bilangan mod 2 EQ 0
cetak positif>cek apakah bilangan mod 2 EQ 0
cetak negatif>cek apakah bilangan mod 2 EQ 0
cek apakah bilangan mod 2 EQ 0>cetak genap:ya
cek apakah bilangan mod 2 EQ 0>cetak ganjil:tidak
cetak genap>selesai
cetak ganjil>selesai

Gabung semua file TS dalam 1 folder menjadi 1 file Video

Gabungkan semua file ts ke dalam 1 file dengan ffmpeg

@echo off
setlocal


REM Define the directory to search for .ts files
set "directory=."

REM Define the output file
set "inputfile=sorted_ts_files.txt"

REM List all .ts files, sort them, and output to the text file
dir /b "%directory%\*.ts" | sort > "%inputfile%"

REM Notify the user
echo Sorted list of .ts files has been saved to %inputfile%


REM Define the input and output files
set "inputfile=sorted_ts_files.txt"
set "concatfile=concat_list.txt"
set "outputfile=output.ts"

REM Check if the input file exists
if not exist "%inputfile%" (
    echo Input file %inputfile% does not exist.
    exit /b 1
)

REM Create the concat file for ffmpeg
echo Creating concat file for ffmpeg...
> "%concatfile%" (
    for /f "usebackq delims=" %%a in ("%inputfile%") do echo file '%%a'
)

REM Join the video files using ffmpeg
echo Joining video files...
ffmpeg -f concat -safe 0 -i "%concatfile%" -c copy "%outputfile%"

REM Cleanup
del "%concatfile%"
del "%inputfile%"
echo Done. The output file is %outputfile%.

endlocal

Scraping DDG dengan python

from duckduckgo_search import DDGS
from pathlib import Path
from fastprogress.fastprogress import progress_bar
import requests
import uuid
from PIL import Image as PImage

root = Path().cwd()/"jilbabcantik"  #isikan nama folder
keywords = 'jilbab cantik'          #isikan kata kunci
max_results=20

links=[]
with DDGS(proxies="socks5://localhost:9150", timeout=20) as ddgs:
    ddgs_images_gen = ddgs.images(
      keywords,
      safesearch="off",
    )
    for r in ddgs_images_gen:    
        #print(r["image"])
        links.append(r["image"])
        if len(links) >= max_results:
            break


if(len(links) == 0):
    print("Tidak ada yang bisa diunduh!");

uuid_names=True
path = Path(root)
path.mkdir(parents=True, exist_ok=True)

print("Mengunduh hasil ke dalam", path)
pbar = progress_bar(links)
pbar.comment = 'Gambar yang diunduh'

i = 1
mk_uniq = lambda : '_' + str(uuid.uuid4())[:8] if uuid_names else ''
mk_fp = lambda x: path/(str(x).zfill(3) + mk_uniq() + ".jpg")
is_file = lambda x: len(list(path.glob(str(x).zfill(3) + '*.jpg'))) > 0

while is_file(i): i += 1 

results = []

for link in pbar:
      try:
        resp = requests.get(link)
        fp = mk_fp(i)
        fp.write_bytes(resp.content)

        try:
          img = PImage.open(fp)
          img.verify()
          img.close()
          results.append(Path(fp))
        except Exception as e:
          print(e)
          print(fp, " tidak valid")
          fp.unlink()
      except Exception as e:
         print(e)
         print("Terjadi pengecualian saat mengambil ", link)

      i += 1


Download MP3 dari YouTube dan situs lain degan JDownloader 2

//Add your script here. Feel free to use the available api properties and methods
if (link.finished) {
    var input = link.downloadPath;
    var output = input.replace(/(aac|m4a|ogg)$/, "mp3");

    if (input != output) {
        try {
            var ffmpeg = callAPI("config", "get", "org.jdownloader.controlling.ffmpeg.FFmpegSetup", null, "binarypath");
            var bitrate = callSync(ffmpeg, "-i", input).match(/bitrate: (\d+) kb/)[1];

            callAsync(function(error) {
                !error && getPath(input).delete();
            }, ffmpeg, "-y", "-i", input, "-b:a", bitrate + "k", output);
        } catch (e) {};
    }
}

Fix ampersamp in syntaxhighlighter

This can be done directly from the webinterface. Just go to Plugins -> Plugin Editor -> select the Plugin SyntaxHighlighter Evolved -> add the snippet to the end

/**
 * Filter to fix issue with & in SyntaxHighlighter Evolved plugin.
 *
 * @param string $code Code to format.
 * @param array $atts Attributes.
 * @param string $tag Tag.
 *
 * @return string
 */
function kagg_syntaxhighlighter_precode( $code, $atts, $tag ) {
    if ( 'code' === $tag ) {
        $code = wp_specialchars_decode( $code );
    }
    return $code;
}
add_filter( 'syntaxhighlighter_precode', 'kagg_syntaxhighlighter_precode', 10, 3 );

Sumber: https://nocin.eu/wordpress-syntaxhighlighter-ampersand-character/

Antarmuka Port Serial dengan C++

Gunakan Class Serial berikut:

//File: Serial.h
#ifndef SERIALCLASS_H_INCLUDED
#define SERIALCLASS_H_INCLUDED

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>

class Serial
{
    private:
        //Serial comm handler
        HANDLE hSerial;
        //Connection status
        bool connected;
        //Get various information about the connection
        COMSTAT status;
        //Keep track of last error
        DWORD errors;

    public:
        //Initialize Serial communication with the given COM port
        Serial(char *portName);
        //Close the connection
        ~Serial();
        //Read data in a buffer, if nbChar is greater than the
        //maximum number of bytes available, it will return only the
        //bytes available. The function return -1 when nothing could
        //be read, the number of bytes actually read.
        int ReadData(char *buffer, unsigned int nbChar);
        //Writes data from a buffer through the Serial connection
        //return true on success.
        bool WriteData(char *buffer, unsigned int nbChar);
        //Check if we are actually connected
        bool IsConnected();


};

#endif // SERIALCLASS_H_INCLUDED

//File: Serial.cpp
#include "Serial.h"

Serial::Serial(char *portName)
{
    //We're not yet connected
    this->connected = false;

    //Try to connect to the given port throuh CreateFile
 #if _MSC_VER && !__INTEL_COMPILER
    const size_t cSize = strlen(portName) + 1;
    wchar_t* wc = new wchar_t[cSize];
    mbstowcs_s(NULL, wc, cSize, portName, cSize);
    this->hSerial = CreateFile(wc,
        GENERIC_READ | GENERIC_WRITE,
        0,
        NULL,
        OPEN_EXISTING,
        FILE_ATTRIBUTE_NORMAL,
        NULL);
#else
    //Try to connect to the given port throuh CreateFile
    this->hSerial = CreateFile(portName,
        GENERIC_READ | GENERIC_WRITE,
        0,
        NULL,
        OPEN_EXISTING,
        FILE_ATTRIBUTE_NORMAL,
        NULL);
#endif

    //Check if the connection was successfull
    if(this->hSerial==INVALID_HANDLE_VALUE)
    {
        //If not success full display an Error
        if(GetLastError()==ERROR_FILE_NOT_FOUND){

            //Print Error if neccessary
            printf("ERROR: Handle was not attached. Reason: %s not available.\n", portName);

        }
        else
        {
            printf("ERROR!!!");
        }
    }
    else
    {
        //If connected we try to set the comm parameters
        DCB dcbSerialParams = {0};

        //Try to get the current
        if (!GetCommState(this->hSerial, &dcbSerialParams))
        {
            //If impossible, show an error
            printf("failed to get current serial parameters!");
        }
        else
        {
            //Define serial connection parameters for the arduino board
            dcbSerialParams.BaudRate=CBR_9600;
            dcbSerialParams.ByteSize=8;
            dcbSerialParams.StopBits=ONESTOPBIT;
            dcbSerialParams.Parity=NOPARITY;
            //Setting the DTR to Control_Enable ensures that the Arduino is properly
            //reset upon establishing a connection
            dcbSerialParams.fDtrControl = DTR_CONTROL_ENABLE;

             //Set the parameters and check for their proper application
             if(!SetCommState(hSerial, &dcbSerialParams))
             {
                printf("ALERT: Could not set Serial Port parameters");
             }
             else
             {
                 //If everything went fine we're connected
                 this->connected = true;
                 //Flush any remaining characters in the buffers
                 PurgeComm(this->hSerial, PURGE_RXCLEAR | PURGE_TXCLEAR);
                 //We wait 2s as the arduino board will be reseting
                 Sleep(2000);
             }
        }
    }

}

Serial::~Serial()
{
    //Check if we are connected before trying to disconnect
    if(this->connected)
    {
        //We're no longer connected
        this->connected = false;
        //Close the serial handler
        CloseHandle(this->hSerial);
    }
}

int Serial::ReadData(char *buffer, unsigned int nbChar)
{
    //Number of bytes we'll have read
    DWORD bytesRead;
    //Number of bytes we'll really ask to read
    unsigned int toRead;

    //Use the ClearCommError function to get status info on the Serial port
    ClearCommError(this->hSerial, &this->errors, &this->status);

    //Check if there is something to read
    if(this->status.cbInQue>0)
    {
        //If there is we check if there is enough data to read the required number
        //of characters, if not we'll read only the available characters to prevent
        //locking of the application.
        if(this->status.cbInQue>nbChar)
        {
            toRead = nbChar;
        }
        else
        {
            toRead = this->status.cbInQue;
        }

        //Try to read the require number of chars, and return the number of read bytes on success
        if(ReadFile(this->hSerial, buffer, toRead, &bytesRead, NULL) && bytesRead != 0)
        {
            return bytesRead;
        }

    }

    //If nothing has been read, or that an error was detected return -1
    return -1;

}


bool Serial::WriteData(char *buffer, unsigned int nbChar)
{
    DWORD bytesSend;

    //Try to write the buffer on the Serial port
    if(!WriteFile(this->hSerial, (void *)buffer, nbChar, &bytesSend, 0))
    {
        //In case it don't work get comm error and return false
        ClearCommError(this->hSerial, &this->errors, &this->status);

        return false;
    }
    else
        return true;
}

bool Serial::IsConnected()
{
    //Simply return the connection status
    return this->connected;
}


Berikut contoh koneksi pengiriman data

#include <iostream>
#include "windows.h"
#include "Serial.h"

#include <thread>
#include <chrono>

using namespace std;

void delay(int ms){
    std::this_thread::sleep_for (std::chrono::milliseconds(ms));
}

int main(int argc, char** argv) {

    char alamatPort[] = "\\\\.\\COM7";
    Serial* s = new Serial(alamatPort);

	char dataOn[256] = "on1\n"; //"Nyala!";
	char dataOff[256] = "off0\n"; //"mati!";

	cout<<"isikan angka 1 untuk menyalakan, atau 0 untuk mematikan"<<endl;


	int jawab;
	do{
        cin>>jawab;;

        if(jawab==0)
            s->WriteData(dataOff, sizeof(dataOff));
        if(jawab==1)
            s->WriteData(dataOn, sizeof(dataOn));
        if(jawab==2)
            for(int a=0;a<5;a++){
                s->WriteData(dataOn, sizeof(dataOn));
                delay(500);
                s->WriteData(dataOff, sizeof(dataOff));
                delay(500);
            }
	}while(jawab<3);

	return 0;
}

Berikut contoh untuk mengirim dan menerima data

#include <iostream>
#include <stdio.h>
#include <tchar.h>
#include "Serial.h" // Library described above
#include <string>


/* run this program using the console pauser or add your own getch, system("pause") or input loop */
char alamatPort[] = "\\\\.\\COM7";
Serial* SP = new Serial(alamatPort);    // adjust as needed

void* baca(void* data)
{

    char incomingData[256] = "";            // don't forget to pre-allocate memory
    //printf("%s\n",incomingData);
    int dataLength = 256;
    int readResult = 0;


    while (SP->IsConnected())
    {
        readResult = SP->ReadData(incomingData, dataLength);
        if (readResult > 0) {
            printf("%s\n", incomingData);
        }
        //printf("Bytes read: (-1 means no data available) %i\n",readResult);

        //std::string test(incomingData);

        //printf("%s",incomingData);
        //test = "";

        Sleep(500);
    }
    return NULL;
}

void* tulis(void* data)
{
    while (SP->IsConnected())
    {
        char outgoingData[256] = "";
        char keluar[256] = "keluar";
        int dataLength = sizeof(outgoingData);        // don't forget to pre-allocate memory
        scanf_s("%255s", outgoingData, dataLength);

        if (outgoingData != "")
        {
            if (strcmp(outgoingData, "OK") == 0) {
                printf("Pengiriman selesai\n");
                return NULL;

            }
            if (SP->WriteData(outgoingData, dataLength))
            {
                printf("Data send:%s\n", outgoingData);
            }
        }

        Sleep(500);
    }
    // do stuff...
    return NULL;
}

#if _MSC_VER && !__INTEL_COMPILER
#include <thread>

int main(int argc, char** argv) {
    printf("Welcome to the serial test app!\n\n");
    if (SP->IsConnected())
        printf("Serial sudah terhubung\n");
    int status;
    std::thread thrd_1(baca,(void*)0);
    std::thread thrd_2(tulis, (void*)0);

    thrd_1.join();
    thrd_2.join();

}
#else
// thread example
#include <pthread.h>

int main(int argc, char** argv) {
    printf("Welcome to the serial test app!\n\n");
    if (SP->IsConnected())
        printf("Serial sudah terhubung\n");

    pthread_t thrd_1;
    pthread_t thrd_2;
    int status;

    pthread_create(&thrd_1, NULL, baca, (void*)0);
    pthread_create(&thrd_2, NULL, tulis, (void*)0);

    pthread_join(thrd_1, (void**)&status);
    pthread_join(thrd_2, (void**)&status);

    printf("Terima kasih");

    return 0;
}
#endif

String dan Pointer C++

typedef struct
{
  int x, y;
  short life;
  char *nama;
} Man;

void setup() {
  Serial.begin(9600);

  //menggunakan 4 memori untuk string
  String hi = "Hello";
  String names = "World";
  String hello = hi + " " + names;

  //menggunakan 1 memori
  String greeting = hi;
  greeting.concat(" ");
  greeting.concat(names);



  String tempname = "Temperature";
  String temp = "23C";
  PrintVal1(tempname, temp); //membuat string redundan. Lihat fungsi
  PrintVal2(tempname, temp); //pass by reference, tidak redundan. Lihat fungsi

  char thestring[30] = "This is a string";
  //thestring = "New content"; //cara yang salah, panjang string harus sama!
  strcpy(thestring, "New content"); //good method

  char isgood[8] = "is good";
  //char allbad[38] = thestring + isgood; //cara yang salah, ini adalah operasi biner. gunakan strcat
  char allgood[38];
  strcat(allgood, thestring); strcat(allgood, isgood);



  char a[2] = "A"; char b[2] = "A";
  if (a == b) {}//cara yang salah, akan selalu bernilai false
  if (strcmp(a, b) == 0 ) {} //car yang benar, atau gunakan strcasecmp()


  //pointer
  int var = 0;
  int arr[] = {1, 2, 3};
  int *ptr;           //init, don't set to NULL (destroy), *ptr = 0, first address? no!
  ptr = &var;         //to address of var, not the value of var
  *ptr = 50;;         //pointer content is 50
  //ptr = 50;         //pointer (address) is 50
  //ptr++;            //pointer address + 1

  ptr = arr;         //to array
  ptr[0] = 50;      //array number 0, is 50
  ptr = &arr[0];     //equal to above, array number 0 is 50

  Man *ptrMan;
  Man manusia = {0, 0, 0, NULL};
  manusia.life = 9;       //kucing :D
  manusia.nama = "Todol"; //pointer in struct
  ptrMan = &manusia;
  ptrMan-> life = 0;         //mati
  
  char *pString = "This is text"; //not safe to change content! don't do!
  const char *pStringSafe = "This is text"; //display warning when change content

  char temperature[] = "23C"; //constant
  //Following syntax is not compiler friendly, it will be unhappy
  PrintValP("Temperature", temperature);
  //The following will make compiler happier (look at the fuction!)
  PrintValPC("Temperature", temperature);

  PrintString(temperature);
}


//make 2 new strings, redundant string
void PrintVal1(String tag, String value) {
  Serial.print(tag);
  Serial.print(" = ");
  Serial.println(value);
}

//pass by reference
void PrintVal2(String &tag, String &value) {
  Serial.print(tag);
  Serial.print(" = ");
  Serial.println(value);
}

//pass by pointer
void PrintValP(char *tag, char *value) {
  Serial.print(tag);
  Serial.print(" = ");
  Serial.println(value);
}
void PrintValPC(const char *tag, const char *value) {
  Serial.print(tag);
  Serial.print(" = ");
  Serial.println(value);
}
void PrintString(const char *str) {
  const char *p;
  p = str;
  while (*p) {
    Serial.print(*p);
    p++;
  }
}

void loop() {
  // put your main code here, to run repeatedly:

}

Raspberry Bluetooth Printer

You have to perform several steps in order to establish communication.

You have to pair your desired bluetooth device using bluetoothctl

sudo bluetoothctl -a

scan on

devices

pair XX:XX:XX:XX:XX:XX

trust XX:XX:XX:XX:XX:XX

quit

Where XX:XX:XX:XX:XX:XX is the MAC address of your bluetooth device.

You have to create the serial device that binds to your paired bluetooth device.

sudo rfcomm bind /dev/rfcomm0 XX:XX:XX:XX:XX:XX 1

The last number is the communication channel. It has to bee unique for all your connections.

Then you should be able to open a connection. (Assuming your bluetooth device actually supports the required SPP protocol.)

echo “test” > /dev/rfcomm0

source: https://raspberrypi.stackexchange.com/questions/78155/using-dev-rfcomm0-in-raspberry-pi/78301#78301?s=39be540452a34b55af09cb19d04ea700