Skip to content

Instantly share code, notes, and snippets.

View umidjons's full-sized avatar
🏠
Working from home

Umid umidjons

🏠
Working from home
View GitHub Profile
@umidjons
umidjons / split-join-files.sh
Created January 13, 2014 06:13
Split the file into 50 MB pieces with the given prefix
# split into chunks:
$ split --bytes=50M logdata part_
$ ls -lh
total 204M
-rw------- 1 sathiya sathiya 102M Jul 25 18:47 logdata
-rw------- 1 sathiya sathiya 50M Jul 25 19:23 part_aa
-rw------- 1 sathiya sathiya 50M Jul 25 19:23 part_ab
-rw------- 1 sathiya sathiya 1.6M Jul 25 19:23 part_ac
@umidjons
umidjons / youtube-dl-download-audio-only-on-best-quality.md
Last active March 9, 2024 07:54
Download Audio from YouTube with youtube-dl

Download Audio from YouTube

-i - ignore errors

-c - continue

-t - use video title as file name

--extract-audio - extract audio track

@umidjons
umidjons / random-hash-string-php.md
Created April 29, 2015 10:56
Generate random hash string in PHP

Generate random hash string in PHP

<?php
function randHash($len=32)
{
	return substr(md5(openssl_random_pseudo_bytes(20)),-$len);
}
@umidjons
umidjons / compile-package-in-sqlplus.md
Last active February 16, 2024 12:52
Compile package in sqlplus

Compile all objects in schema

EXEC DBMS_UTILITY.compile_schema(schema => 'MYSCHEMA');

Compile package in sqlplus

Compile package header and body with following two statements

@umidjons
umidjons / dos2unix.md
Created July 18, 2014 04:55
Execute dos2unix for directory recursively.

Will recursively find all files inside current directory and call for these files dos2unix command. Would break if you had spaces in file name.

find . -type f -exec dos2unix {} \;

Wouldn't break if you had spaces in file names.

find . -type f -print0 | xargs -0 dos2unix
@umidjons
umidjons / sort-object-properties-by-value.md
Last active January 16, 2024 13:00
JavaScript: sort object properties by value (numeric or string)

Sort object properties by value (values are text)

I have following object:

var cities={10:'Tashkent', 14:'Karakalpakiya', 16:'Andijan'};

I want sort it by city names, so after sort it should be:

var cities={16:'Andijan', 14:'Karakalpakiya', 10:'Tashkent'};

But I can't sort object properties, instead can convert object into array, then sort items.

@umidjons
umidjons / index.html
Last active January 6, 2024 18:46
Upload File using jQuery.ajax() with progress support
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Upload File using jQuery.ajax() with progress support</title>
</head>
<body>
<input type="file" name="file" id="sel-file"/>
@umidjons
umidjons / yii-cgridview-custom-button-ajax.md
Last active January 2, 2024 20:17
Yii: custom button in CGridView with AJAX functionality

#Approve/Unapprove comments

Create approve action in our controller:

<?php
class CommentsController extends Controller
{
	// ...
	public function actionApprove( $id, $oper = NewsComments::STATUS_APPROVED )
	{
@umidjons
umidjons / walk-dom-with-callback.js
Created October 7, 2013 09:54
Traverse DOM elements recursively.
var walkDom=function(html_elem, func)
{
if(typeof func!='function') return;
var loop=function(html_elem)
{
do
{
func(html_elem); // call callback for every element
if(html_elem.hasChildNodes())
loop(html_elem.firstChild);
@umidjons
umidjons / pdf-thumbnail-php.md
Last active December 6, 2023 21:41
Creating PDF thumbnails in PHP

Creating PDF thumbnails in PHP

Install Ghostscript

Download and install right version of ghostscript. In my case my PHP was x86 architecture, so I download Ghostscript 9.14 for Windows (32 bit).

Enable ImageMagick