1000+ micro code pieces with clear explanation @ onelinerhub.com

Overview

Onelinerhub

Lib of micro code pieces, well explained and mostly single-line solutions @ onelinerhub.com.

Why we do it and where we go

We're building non-profit opensource code hub to address following issues:

  • clear simple modern solutions for repeatable coding challeges
  • moderated single-standard solutions instead of "here's a list of 25 answers with 125 comments"
  • code parts explanations to fight dumb copy-paste, but educate instead
  • no ads, no paid access, just community contributions and usefulness instead of profits

Help by contributing

Feel free to add/update any tech code piece you find useful.

Principles

  • 3 main principles for code pieces here are: simple, modern, minimal
  • Micro solutions are ment to solve specific issue in modern versions of technologies (browsers, compilers, databases, etc.)
  • Solution should be as short and simple as possible
  • Solution should be explained by components (variables, functions, operations, etc.)
  • Image illustrations are welcome

Code file micro-format

  • Each code file should be placed in it's main technology folder (e.g. "php", "bash", etc).
  • File should have short but understandable naming in underscore format (e.g. "redirect_header.md")
  • Extension is always ".md", so all the markdown works
  • File must include title ("# title") as the first line (technology title is automatically added in UI {title} #{technology})
  • File must include actual code snippet in the highlighted code block
  • File should also include code parts description, so it's well explained (example in template)
  • File can also include group definition to link similar solution (e.g. different date formats or string comparison methods)
  • You can upload PNG file with the same file name as the code file and it will automatically be rendered in UI
  • Example can be specified using ## Example header followed by 2 code blocks (input and output examples)

Use this template for creating new code pieces.

FAQ

"What if I want to create new folder/technology in onelinerhub repo?"

You are welcome to do it with pull request as long as it is useful technology/solution for engineers

"What if I want to edit some published code?"

You are welcome to do it with pull request as long as it will make the code better (simple, modern, minimal)

"Can I post multi-line code (not a one-liner)?"

Yes, as long as the solution is targeted towards specific problem and is well explained

API

We're happy to provide our code collection for integrations of all types. At this point, search API is available publicly with no need to register any keys.

Usage is as simple as calling api.onelinerhub.com/search endpoint with quqery parameter (GET or POST):

curl "https://api.onelinerhub.com/search?query=php+header+json"

You'll get JSON array with the following objects:

{
  "url": "...", // public URL of the code piece page
  "tech": "...", // technology of this code
  "subject": "...", // Full title for the code
  "lang": "...", // Code piece language
  "code": "..." // Code piece itself
}

Example:

[
    {
        "url": "https:\/\/onelinerhub.com\/javascript\/fetch_post_uri",
        "tech": "javascript",
        "subject": "Ajax post x-www-form-urlencoded data",
        "lang": "javascript",
        "code": "fetch('\/backend.php', {\n  method: 'post',\n  headers: { 'Content-Type': 'application\/x-www-form-urlencoded;charset=UTF-8' },\n  body: 'var1=' + encodeURIComponent('Donald Trump :(') + '&var2=123'\n}).then(function(r) {\n  return r.json();\n}).then(function(data) {\n  console.log(data);\n});"
    },
    {
        "url": "https:\/\/onelinerhub.com\/php\/json_content_type",
        "tech": "php",
        "subject": "Set content type to JSON",
        "lang": "php",
        "code": "header('Content-Type: application\/json');\necho json_encode([]);"
    }
]

Integrations

Comments
  • Short solution needed:

    Short solution needed: "How to fold" (vim)

    Please help us write most modern and shortest code solution for this issue: How to fold (technology: vim)

    Fast way

    Just write the code solution in the comments.

    Prefered way

    1. Create pull request with a new code file inside inbox folder.
    2. Don't forget to use comments to make solution explained.
    3. Link to this issue in comments of pull request.
    help wanted good first issue code vim 
    opened by nonunicorn 7
  • Can't scroll past first page

    Can't scroll past first page

    Using Firefox (actually Waterfox Classic), looking at Python one-liners -- can only view first page. No way to scroll further, either with cursor or arrow keys.

    testing 
    opened by allears 7
  • Short solution needed:

    Short solution needed: "How to get unique values" (python-pandas)

    Please help us write most modern and shortest code solution for this issue: How to get unique values (technology: python-pandas)

    Fast way

    Just write the code solution in the comments.

    Prefered way

    1. Create pull request with a new code file inside inbox folder.
    2. Don't forget to use comments to make solution explained.
    3. Link to this issue in comments of pull request.
    help wanted good first issue code python-pandas 
    opened by nonunicorn 6
  • Short solution needed:

    Short solution needed: "How to change password in CLI" (ubuntu)

    Please help us write most modern and shortest code solution for this issue: How to change password in CLI (technology: ubuntu)

    Fast way

    Just write the code solution in the comments.

    Prefered way

    1. Create pull request with a new code file inside inbox folder.
    2. Don't forget to use comments to make solution explained.
    3. Link to this issue in comments of pull request.
    help wanted good first issue code ubuntu 
    opened by nonunicorn 5
  • Write shortest possible code: How to lowercase a string (python)

    Write shortest possible code: How to lowercase a string (python)

    Please write shortest code example for this question: How to lowercase a string in python

    How to do it:

    1. Go to python codes
    2. Create new file (named in underscore case, should contain key words from title) with md extension (markdown file).
    3. Propose new file with following content (please use all three blocks if possible - title, code itself and explanations list):
    # How to lowercase a string
    
    ```python
    code part1 part2 part3 ...
    ```      
    
    - part1 - explain code part 1
    - part2 - explain code part 2
    - ...
    

    More advanced template for examples and linked solutions. More docs here.

    help wanted good first issue code python hacktoberfest 
    opened by nonunicorn 5
  • Short solution needed:

    Short solution needed: "How to iterate Numpy array in loop" (python-numpy)

    Please help us write most modern and shortest code solution for this issue: How to iterate Numpy array in loop (technology: python-numpy)

    Fast way

    Just write the code solution in the comments.

    Prefered way

    1. Create pull request with a new code file inside inbox folder.
    2. Don't forget to use comments to make solution explained.
    3. Link to this issue in comments of pull request.
    help wanted good first issue code python-numpy 
    opened by nonunicorn 4
  • Suggested copy area

    Suggested copy area

    In chart.js code pieces it's more convenient to copy just a part of configuration options by default, instead of whole code example. Think of creating new markup way to highlight default copying area in such cases.

    enhancement 
    opened by nonunicorn 4
  • Short solution needed:

    Short solution needed: "How to plot data frame" (python-pandas)

    Please help us write most modern and shortest code solution for this issue: How to plot data frame (technology: python-pandas)

    Fast way

    Just write the code solution in the comments.

    Prefered way

    1. Create pull request with a new code file inside inbox folder.
    2. Don't forget to use comments to make solution explained.
    3. Link to this issue in comments of pull request.
    help wanted good first issue code python-pandas 
    opened by nonunicorn 3
  • Short solution needed:

    Short solution needed: "How to use multiple conditions in where" (python-numpy)

    Please help us write most modern and shortest code solution for this issue: How to use multiple conditions in where (technology: python-numpy)

    Fast way

    Just write the code solution in the comments.

    Prefered way

    1. Create pull request with a new code file inside inbox folder.
    2. Don't forget to use comments to make solution explained.
    3. Link to this issue in comments of pull request.
    help wanted good first issue code python-numpy 
    opened by nonunicorn 3
  • Short solution needed:

    Short solution needed: "How to check Numpy version" (python-numpy)

    Please help us write most modern and shortest code solution for this issue: How to check Numpy version (technology: python-numpy)

    Fast way

    Just write the code solution in the comments.

    Prefered way

    1. Create pull request with a new code file inside inbox folder.
    2. Don't forget to use comments to make solution explained.
    3. Link to this issue in comments of pull request.
    help wanted good first issue code python-numpy 
    opened by nonunicorn 3
  • Short solution needed:

    Short solution needed: "How to count unique values" (python-numpy)

    Please help us write most modern and shortest code solution for this issue: How to count unique values (technology: python-numpy)

    Fast way

    Just write the code solution in the comments.

    Prefered way

    1. Create pull request with a new code file inside inbox folder.
    2. Don't forget to use comments to make solution explained.
    3. Link to this issue in comments of pull request.
    help wanted good first issue code python-numpy 
    opened by nonunicorn 3
Releases(6.0)
  • 6.0(Dec 16, 2022)

  • 4.0(Mar 29, 2022)

    ace 6 pieces

    bash 44 pieces

    bulma 1 pieces

    c 18 pieces

    c# 6 pieces

    certbot 15 pieces

    chart.js 12 pieces

    chrome-extension 59 pieces

    clickhouse 139 pieces

    css 24 pieces

    curl 64 pieces

    django 2 pieces

    docker 51 pieces

    ffmpeg 27 pieces

    find 19 pieces

    git 83 pieces

    golang 24 pieces

    google-chrome 10 pieces

    grep 13 pieces

    html 50 pieces

    htpasswd 2 pieces

    http-headers 2 pieces

    imagemagick 9 pieces

    java 7 pieces

    javascript 122 pieces

    jpegoptim 3 pieces

    jq 5 pieces

    jquery 45 pieces

    ls 6 pieces

    lua 80 pieces

    lua-mysql 9 pieces

    lua-redis 24 pieces

    manticoresearch 19 pieces

    matlab 6 pieces

    mysql 61 pieces

    nano 8 pieces

    nginx 94 pieces

    nginx-lua 74 pieces

    nodejs 1 pieces

    optipng 2 pieces

    php 73 pieces

    php-pdo 45 pieces

    php-redis 45 pieces

    php-swoole 16 pieces

    pip 2 pieces

    postgres 17 pieces

    powershell 8 pieces

    python 126 pieces

    python-numpy 76 pieces

    python-pandas 10 pieces

    python-pillow 1 pieces

    python-redis 54 pieces

    react 1 pieces

    redis 53 pieces

    redis-timeseries 18 pieces

    regex 8 pieces

    rust 4 pieces

    solidity 3 pieces

    ssconvert 8 pieces

    ssh 14 pieces

    supervisor 9 pieces

    ubuntu 58 pieces

    ufw 40 pieces

    vim 34 pieces

    webp 6 pieces

    wget 3 pieces

    wordpress 6 pieces

    xdotool 13 pieces

    youtube 2 pieces

    Source code(tar.gz)
    Source code(zip)
  • 2.0(Dec 15, 2021)

    Most popular micro code solutions for PHP/Python with Mysql DB and Nginx webserver, Docker containers, Git VCS and tens of technologies for web engineering.

    Source code(tar.gz)
    Source code(zip)
  • 1.0(Jul 8, 2021)

    3 months ago we've started this hub to collect useful and modern tiny solutions for tiny (but yet important) tasks that arise regularly when developing web apps. Now we've covered most of entry-level web app engineering on top of linux/php/mysql/javascript thanks to our contributors. Next iteration plan is to dive into python/lua/git/go, tens of databases and other technologies/frameworks/platforms/tools for app developers.

    Source code(tar.gz)
    Source code(zip)
Owner
Onelinerhub.com - micro code solutions
Micro code pieces for popular technologies brought by opensource community
Onelinerhub.com - micro code solutions
Reference for writing clear PHP code

clearPHP Reference for writing clear PHP code It is difficult to know when one's code is well written. There are recommendations for writing PHP code

Seguy Damien 947 Dec 22, 2022
A PHP project/micro-package generator for PDS compliant projects or micro-packages.

Construct A PHP project/micro-package generator for PDS compliant projects or micro-packages. Installation Construct should be installed globally thro

Jonathan Torres 263 Sep 28, 2022
All in one Video Downloader - Download videos from facebook twitter youtube tiktok and 1000+ other sites .. made by Vijay Kumar

VKRdownloader Video Downloader by @TherealVKR Vijay Kumar .... Download Video From YouTube , Facebook , Twitter , Instagram , TikTok , And 1000+ Other

Vijay Kumar 35 Dec 29, 2022
Online All in One Video & Audio Downloader From YouTube,Facebook,Twitter,Pinterest,Instagram,MXtakatak,IPL, Tiktok and 1000+ More Sites too

DLhut Contact me If You Find ANy Bug ... PHP Search and Download any Videos from any site. Online All in One Video & Audio Downloader From YouTube,Fac

Vijay Kumar 6 Oct 11, 2021
Online All in One PHP Video & Audio Downloader From YouTube,Facebook,Twitter,Pinterest,Instagram,MXtakatak,IPL, Tiktok and 1000+ More Sites too

DLhut Contact me If You Find ANy Bug ... PHP Search and Download any Videos from any site. Online All in One Video & Audio Downloader From YouTube,Fac

Vijay Kumar 4 Nov 8, 2021
Increase "Death by 1000 needles" attack up to 100x times

Підсили свою атаку у 100 разів разом із db1000nX100 db1000nX100 це Linux контейнер для популярної програми db1000n, щo дозволяє значно підняти ефектив

null 62 Dec 31, 2022
Prequel for Laravel. Clear and concise database management.

TL;DR? Test Prequel here! What is Prequel exactly? Prequel is meant to be a database management tool for Laravel to replace the need for separate stan

Protoqol 1.4k Dec 27, 2022
A foundation for WordPress Plugin Development that aims to provide a clear and consistent guide for building your plugins.

WordPress Plugin Boilerplate A standardized, organized, object-oriented foundation for building high-quality WordPress Plugins. Contents The WordPress

Devin 7.2k Jan 4, 2023
Clear all your logs in [linux/windows] servers 🛡️

Log-killer Log Killer is tool for [Linux/Windows] Servers This tool will delete all your logs just download the tool and run it on the server if your

Rizer 281 Nov 24, 2022
Micro PHP benchmark library

Ubench Ubench is a PHP micro library for benchmark Installation Note: If you are looking for this package for laravel application then install it from

Jeremy Perret 554 Nov 25, 2022
Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.

Slim Framework Slim is a PHP micro-framework that helps you quickly write simple yet powerful web applications and APIs. Installation It's recommended

Slim Framework 11.5k Jan 4, 2023
A tiny, yet powerful, PHP micro-framework.

Equip Framework A tiny and powerful PHP micro-framework created and maintained by the engineering team at When I Work. Attempts to be PSR-1, PSR-2, PS

Equip 118 Jun 24, 2022
[DEPRECATED -- Use Symfony instead] The PHP micro-framework based on the Symfony Components

Silex, a simple Web Framework WARNING: Silex is in maintenance mode only. Ends of life is set to June 2018. Read more on Symfony's blog. Silex is a PH

Silex 3.6k Dec 22, 2022
A resource-oriented micro PHP framework

Bullet Bullet is a resource-oriented micro PHP framework built around HTTP URIs. Bullet takes a unique functional-style approach to URL routing by par

Vance Lucas 415 Dec 27, 2022
An extensible micro-framework for PHP

What is Flight? Flight is a fast, simple, extensible framework for PHP. Flight enables you to quickly and easily build RESTful web applications. requi

Mike Cao 2.5k Dec 30, 2022
A resource-oriented micro PHP framework

Bullet Bullet is a resource-oriented micro PHP framework built around HTTP URIs. Bullet takes a unique functional-style approach to URL routing by par

Vance Lucas 415 Dec 27, 2022
A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast! Condensed in a single ~65KB file

Bong Cosca 2.6k Dec 30, 2022
Silly CLI micro-framework based on Symfony Console

currentMenu home Silly CLI micro-framework based on Symfony Console. Professional support for Silly is available via Tidelift Video introduction in fr

Matthieu Napoli 862 Dec 23, 2022
Rest API boilerplate for Lumen micro-framework.

REST API with Lumen 5.5 A RESTful API boilerplate for Lumen micro-framework. Features included: Users Resource OAuth2 Authentication using Laravel Pas

Hasan Hasibul 484 Sep 16, 2022