Skip to content

Instantly share code, notes, and snippets.

View slavrinja's full-sized avatar

Sergey Lavrenov slavrinja

  • Russia, Saint Petersburg
View GitHub Profile
@slavrinja
slavrinja / serve-laravel.sh
Created April 28, 2020 14:32
Homestead with CORS
#!/usr/bin/env bash
mkdir /etc/nginx/ssl 2>/dev/null
PATH_SSL="/etc/nginx/ssl"
PATH_KEY="${PATH_SSL}/${1}.key"
PATH_CSR="${PATH_SSL}/${1}.csr"
PATH_CRT="${PATH_SSL}/${1}.crt"
if [ ! -f $PATH_KEY ] || [ ! -f $PATH_CSR ] || [ ! -f $PATH_CRT ]
// create a bookmark and use this code as the URL, you can now toggle the css on/off
// thanks+credit: https://dev.to/gajus/my-favorite-css-hack-32g3
javascript: (function() {
var styleEl = document.getElementById('css-layout-hack');
if (styleEl) {
styleEl.remove();
return;
}
styleEl = document.createElement('style');
styleEl.id = 'css-layout-hack';
@slavrinja
slavrinja / js_immediate_interval.js
Last active September 1, 2019 20:45
JS interval with immediate call
setInterval(function hello() {
console.log('world');
return hello;
}(), 5000);
@slavrinja
slavrinja / set_input_value.js
Last active March 16, 2023 11:43
Set input value by core functionality
function setInputField(selector, value)
{
return new Promise(function(resolve, reject) {
object = this.document.querySelector(selector);
if (!object) {
reject(false);
}
document.querySelectorAll(selector).forEach(function (t) {
Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value").set.call(t, value);
@slavrinja
slavrinja / decolor_autofill.scss
Created March 31, 2019 10:13
Reset background of autofilled inputs
// Hack for remove pre-set background for autofilled input values
.form-control,
input {
&:-webkit-autofill,
&:-webkit-autofill:hover,
&:-webkit-autofill:focus,
&:-webkit-autofill:active {
background-color: transparent !important;
-webkit-box-shadow: 0 0 0 1000px transparent inset;
-webkit-transition-property: background-color !important;
@slavrinja
slavrinja / css_arrows.html
Created February 17, 2019 16:02
css arrows example
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
i {
border: solid black;
border-width: 0 3px 3px 0;
display: inline-block;
padding: 3px;
@slavrinja
slavrinja / git-submodules.md
Created February 17, 2019 05:59 — forked from slavafomin/git-submodules.md
Git submodules best practices

Git submodules best practices

Useful commands

— Clone repository with submodules automatically:

git clone --recursive git@github.com:name/repo.git

— Initialize submodules after regular cloning:

@slavrinja
slavrinja / get_url_params.js
Created January 28, 2019 10:39
Getting URL params by JavaScript
//https://html-online.com/articles/get-url-parameters-javascript
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
var mytext = getUrlVars()["text"];
@slavrinja
slavrinja / gdpr_example(jQuery).html
Last active January 24, 2019 09:43
GDPR example
<!--smar7apps gdpr-->
<script>$(document).ready(function(){localStorage.getItem("s7gdpr")||$(".s7gdpr").css("display","flex"),$(".s7gdpr-btn").on("click",function(){localStorage.setItem("s7gdpr",1),$(".s7gdpr").hide()})});</script>
<style>.s7gdpr{display:none;position:fixed;left:0;right:0;bottom:0;background-color:rgba(66,28,166,0.95);background-image: linear-gradient(198deg, #2e42ba, #4250a6);padding:10px;color:rgba(255,255,255,1);z-index:1000;align-items:center;justify-content:flex-end}.s7gdpr-text{font-size: 0.9em;justify-self:flex-start;margin-right:auto}.s7gdpr a{color:rgba(255,255,255,0.9);text-decoration:underline}.s7gdpr a:hover{color:rgba(255,255,255,1)}.s7gdpr-btn{cursor:pointer;margin-left:20px;padding:5px 15px;border:1px solid rgba(255,255,255,0.9);font-size:.9em;color:rgba(255,255,255,0.9);white-space:nowrap;border-radius:3px}.s7gdpr-btn:hover{border:1px solid rgba(255,255,255,1);color:rgba(255,255,255,1)}</style>
<div class="s7gdpr">
<div class="s7gdpr-text">
We use cookies to person
@slavrinja
slavrinja / isFunction.js
Created January 17, 2019 09:46
JavaScript isFunction() check method
function isFunction(functionToCheck) {
return functionToCheck && {}.toString.call(functionToCheck) === '[object Function]';
}