Skip to content

Instantly share code, notes, and snippets.

@lechup
lechup / config-site.php
Last active January 23, 2023 14:43
Piler mailpiler.org - adding aliases on the fly
<?
// based on:
// https://www.mailpiler.org/wiki/current:custom-authentication
$config['CUSTOM_EMAIL_QUERY_FUNCTION'] = 'set_email_aliases';
function set_email_aliases($username = '') {
$session = Registry::get('session');
$data = $session->get("auth_data");
@lechup
lechup / backup.ps1
Last active November 30, 2022 14:09
Scripts to manage backup on Windows 10 machines
# Set-ExecutionPolicy Bypass -Scope Process -Force; or use run.bat
$cred = Import-Clixml .\backup.cred
iex "wbadmin start backup -allCritical -backupTarget:\\backup-server.lan\backup\komputery\ -user:$($cred.UserName) -password:$($cred.GetNetworkCredential().password) -quiet > .\backup.log"
@lechup
lechup / generate-ads.sh
Created October 19, 2022 08:28
SetupAD Generate Ads.txt
#!/usr/bin/env bash
PWD=`pwd`
SCRIPT_DIR=`dirname -- "$0"`
cd $SCRIPT_DIR
wget https://wb.setupad.com/api/getAdsTXT/1793/download -q -O ads-new.txt
if [ `cat ads-new.txt | wc -l` -gt 0 ]; then
echo "setupad.com, 1793, DIRECT" >> ads-new.txt
@lechup
lechup / maintenance-mode-apache.md
Last active October 16, 2017 18:03 — forked from wataruoguchi/How to make your website to maintenance mode.md
How to make maintenance mode - Apache

Apache

How to make your website to maintenance mode

  1. Put maintenance.html into your root directory

  2. Open .htaccess file

  3. Insert this block in the first line of the file

     ErrorDocument 503 /maintenance.html
     RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
    

RewriteCond %{REQUEST_URI} !(/maintenance.html)

@lechup
lechup / Loader.js
Last active July 20, 2017 19:43
React Loader component with react-transition-group Transitions
import React from "react";
import PropTypes from 'prop-types';
import Transition from 'react-transition-group/Transition';
import loaderSrc from "../../img/utils/loader.gif";
import './loader.less'
class Loader extends React.Component {
inTransition = false;
@lechup
lechup / MaterialUI.v.0.18.5.umd.min.js
Last active July 3, 2017 11:12
UMD MaterialUI version to use on jsfiddle, codepen etc., use it like: in here: https://jsfiddle.net/lechup/k52fdwm5
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("React"),require("ReactDOM")):"function"==typeof define&&define.amd?define(["React","ReactDOM"],t):"object"==typeof exports?exports.MaterialUI=t(require("React"),require("ReactDOM")):e.MaterialUI=t(e.React,e.ReactDOM)}(this,function(e,t){return function(e){function t(n){if(o[n])return o[n].exports;var r=o[n]={exports:{},id:n,loaded:!1};return e[n].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var o={};return t.m=e,t.c=o,t.p="",t(0)}([function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.ToolbarTitle=t.ToolbarSeparator=t.ToolbarGroup=t.Toolbar=t.Toggle=t.TimePicker=t.TextField=t.TableRowColumn=t.TableRow=t.TableHeaderColumn=t.TableHeader=t.TableFooter=t.TableBody=t.Table=t.Tab=t.Tabs=t.Snackbar=t.Stepper=t.StepLabel=t.StepContent=t.StepButton=t.Step=t.SvgIcon=t.Subheader=t.Slider=t.SelectField=t.RefreshIndicator=t.RaisedButton=t.RadioButton
@lechup
lechup / deploy.sh
Last active March 17, 2017 12:53
Simple deploy script, should be run from production, it uses screen to maintain connection in case of ssh failure + writes log to deploy.log and deploy.err.log
#!/bin/bash
# cleaning up sudo su "Cannot open your terminal" error
# http://serverfault.com/a/620149/63835
function screen() {
exec /usr/bin/script -q -c "/usr/bin/screen ${*}" /dev/null
}
# run inside screen
# http://unix.stackexchange.com/a/162150/53005
@lechup
lechup / slugify.sql
Last active November 11, 2018 16:54 — forked from thomasbilk/slugify.sql
Pseudo Transliteration for Postgres aka `slugify`
CREATE OR REPLACE FUNCTION slugify(str text) RETURNS text AS $$
BEGIN
RETURN regexp_replace(
lower(translate(str,
'äëïöüáéíóúâêîûôåãõàèìòùřšěčůńýśćłęążźĄŃÝŚĆŁĘÄËÏÖÜÁÉÍÓÚÂÊÎÛÔÅÃÕÀÈÌÒÙŘŠĚČŮŻŹß ²ø®',
'aeiouaeiouaeiouaaoaeioursecunyscleazzANYSCLEAEIOUAEIOUAEIOUAAOAEIOURSECUZzs-2dR'
-- missing chars will be removed
)),
-- strip all others chars than [^a-z0-9 \-]
'[^a-z0-9 \-]',
@media (min-width:480px){.hidden-xs-up{display:none!important}}@media (max-width:480px){.hidden-xs-down{display:none!important}}@media (min-width:768px){.hidden-sm-up{display:none!important}}@media (max-width:768px){.hidden-sm-down{display:none!important}}@media (min-width:992px){.hidden-md-up{display:none!important}}@media (max-width:992px){.hidden-md-down{display:none!important}}@media (min-width:1200px){.hidden-lg-up{display:none!important}}@media (max-width:1200px){.hidden-lg-down{display:none!important}}@media (min-width:1600px){.hidden-lgx-up{display:none!important}}@media (max-width:1600px){.hidden-lgx-down{display:none!important}}
@lechup
lechup / ReflexVisibility.less
Created September 28, 2016 14:18
Responsive visibility utilities for reflex-grid
// Responsive visibility utilities
// reflex-grid
// based on Twitter bootstrap 4
// http://v4-alpha.getbootstrap.com/layout/responsive-utilities/#available-classes
@reflex-xs: 480px;
@reflex-sm: 768px;
@reflex-md: 992px;
@reflex-lg: 1200px;
@reflex-xlg: 1600px;