Skip to content

Instantly share code, notes, and snippets.

View georgebent's full-sized avatar

Yuriy Kr georgebent

View GitHub Profile
@georgebent
georgebent / line-reader.go
Last active June 17, 2023 16:03
Golang line convert: "1 / 3500 then go to Point_282" >>> 282 (get numcer from end)
package main
import (
"fmt"
"os"
"regexp"
"strconv"
)
func main() {
@georgebent
georgebent / docker-clear.txt
Created May 13, 2023 10:12
Docker clear containers
docker system df
docker ps --size
docker container ls -a
docker container rm 4f6468cfddb2
@georgebent
georgebent / openssl.txt
Last active July 3, 2019 15:14
Openssl commands
// make p12 certificate from files
openssl pkcs12 -export -in client.crt -inkey client.key -certfile ca.crt -out client01.p12 -passout pass:pass
@georgebent
georgebent / paginator.blade.php
Created March 21, 2019 08:03
Custom Laravel Paginator
@if (isset($paginator) && $paginator->lastPage() > 1)
<ul class="pagination">
<?php
$interval = isset($interval) ? abs(intval($interval)) : 3 ;
$from = $paginator->currentPage() - $interval;
if($from < 1){
$from = 1;
}
@georgebent
georgebent / informer.ino
Last active March 15, 2019 22:27
Arduino temperature humidity sensor
#include "DHT.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define DHTPIN 4
LiquidCrystal_I2C lcd(0x3F, 16, 2);
DHT dht(DHTPIN, DHT11);
void setup() {
Serial.begin(9600);
@georgebent
georgebent / sql_commands.txt
Last active June 25, 2018 08:23
Commands for SQL dumps
To export
If it's an entire DB, then:
$ mysqldump -u [uname] -p[pass] db_name > db_backup.sql
If it's all DBs, then:
$ mysqldump -u [uname] -p[pass] --all-databases > all_db_backup.sql
If it's specific tables within a DB, then:
$ mysqldump -u [uname] -p[pass] db_name table1 table2 > table_backup.sql
cd /etc/nginx/sites-available/
sudo touch new.site.conf
sudo nano new.site.conf
cd ../sites-enabled
sudo ln -s ../sites-available/new.site.conf .
sudo mcedit /etc/hosts
sudo nginx -t
@georgebent
georgebent / htpassword.txt
Last active November 20, 2017 18:11
Auth for pages by htaceess
// for passwords add to ht.access
AuthType Basic
AuthName "Private zone. Only for administrator!"
AuthUserFile /home/path/to/site.dev/.htpasswd
require valid-user
// and run command
htpasswd -c /home/path/to/site.dev/.htpasswd admin
@georgebent
georgebent / updating node
Last active May 11, 2018 08:27
node update commands
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
# if not working
sudo ln -sf /usr/local/n/versions/node/<VERSION>/bin/node /usr/bin/nodejs
@georgebent
georgebent / loadStyles.js
Last active October 19, 2017 15:38
optimizeCSSLoading
var loadDeferredStyles = function() {
var addStylesNode = document.getElementById("deferred-styles");
var replacement = document.createElement("div");
replacement.innerHTML = addStylesNode.textContent;
document.body.appendChild(replacement)
addStylesNode.parentElement.removeChild(addStylesNode);
};
var raf = requestAnimationFrame || mozRequestAnimationFrame ||
webkitRequestAnimationFrame || msRequestAnimationFrame;
if (raf) raf(function() { window.setTimeout(loadDeferredStyles, 0); });