Skip to content

Instantly share code, notes, and snippets.

View puncoz's full-sized avatar
🇳🇵
Working from home

Puncoz Nepal puncoz

🇳🇵
Working from home
View GitHub Profile

Postgress Important commands

Restart auto-increment counter

ALTER SEQUENCE project_detail_question_category_id_seq RESTART WITH 1

Spotify Control Commands for terminal

General syntax

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.{{Command}}

Play

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Play

Pause

@puncoz
puncoz / readable-number.php
Created December 16, 2017 04:37
Some functions, that help u get readable number. For example: 5145=>5,1K 3465645=>3,4M 4544353454=>4.5B 345,45=>345
<?php
function readable_number($number, $discharge = 0, $fractional = null, $fractional_count = 1)
{
$int_number = intval($number);
if($int_number > 999)
{
$num = substr($int_number, 0, strlen($int_number) - 3);
$discharge++;
@puncoz
puncoz / arch-missing-keyring.md
Last active April 19, 2025 22:47
Arch Linux: missing keyring issue on updates

error: key "CEB167EFB5722BD6" could not be looked up remotely error: required key missing from keyring error: failed to commit transaction (unexpected error)

$ sudo pacman-key --lsign-key CEB167EFB5722BD6

if this gives error ERROR: CEB167EFB5722BD6 could not be locally signed.

$ sudo pacman-key --refresh-keys

@puncoz
puncoz / anaconda.md
Last active December 29, 2018 08:48
Anaconda Basic Commands for linux
@puncoz
puncoz / linux-command.md
Created January 14, 2018 15:21
Basic linux commands.
  1. To prints detailed information about all PCI buses and devices in the system
$ lspci

to get specific pci buses info

$ lspci | grep -i nvidia
@puncoz
puncoz / advance-nginx-config.md
Last active March 26, 2018 05:15
Advanced nginx configuration: Extra security & performance tuning. Original Source https://github.com/getgrav/grav/issues/1625

Advanced configuration for nginx

There are some small changes you can make to make your website faster, and a little more secure.

Security enhancements

The original configuration will keep you safe, but it is always good to see what else can be done.

Giving less information to attackers

By default, the nginx.conf will return "403 Forbidden" errors for system files that are not supposed to be accessed directly. However, there's a good alternative, like so:

@puncoz
puncoz / uniqid.php
Created May 13, 2018 05:20
alternative to uniqid() in php
function cryptoUniqid(string $prefix = '', bool $prng = false): string
{
static $nonce = null;
if($prng || is_null($nonce)) {
$nonce = random_bytes(16);
} else {
sodium_increment($nonce);
}
$m = microtime(true);
$return = sprintf("%8x%05x", floor($m), ($m-floor($m))*1000000);
@puncoz
puncoz / file.php
Created June 12, 2018 17:10 — forked from bainternet/file.php
a Simple class to convert number to words in php based on http://www.karlrixon.co.uk/writing/convert-numbers-to-words-with-php/
<?php
//simple class to convert number to words in php based on http://www.karlrixon.co.uk/writing/convert-numbers-to-words-with-php/
if ( !class_exists('NumbersToWords') ){
/**
* NumbersToWords
*/
class NumbersToWords{
public static $hyphen = '-';
public static $conjunction = ' and ';
@puncoz
puncoz / js-helpers.js
Last active April 5, 2019 08:26
Some useful javascript helper functions.
export const kebabToPascalCase = str.replace(/(?:^\w|[A-Z]|\b\w)/g, (letter, index) => letter.toUpperCase()).replace(/[^\w]+/g, "");
// eg: some-string => SomeString
export const toNepaliNumber = n => (n + '').replace(/\d/g, i => '०१२३४५६७८९'[i])
export const numberToWord = amount => {
const a = ["", "One ", "Two ", "Three ", "Four ", "Five ", "Six ", "Seven ", "Eight ", "Nine ", "Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ", "Fifteen ", "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen"];
const b = ["", "Ten", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"];
amount = (amount.toFixed(2)).toString().split(".");