Create a Custom Hook

This hook can be used with **Advanced Cron Manager**. Simply create a cron job within the plugin and call the hook **get_jobs_from_feed**.
<?php 

function get_jobs_from_feed() {
    do_action('get_jobs_from_feed');
}

function get_jobs() {
  global $wpdb;
  $table_name = "jobs";
  $wpdb->query("TRUNCATE TABLE $table_name");
  $jobs = array();
  
  // ...
  // ...
  
  foreach($jobs as $job):
    $wpdb->insert($table_name, [
        'req_id'    => $job['REQNUMBER'],
        'title'     => $job['JOBTITLE'],
        'category'  => getJobCategory($job['JOBTITLE']),
        'city'      => $job['LOCATIONCITY'], 
        'state'     => convertState($job['LOCATIONSTATE']), 
        'location'  => $job['JOBLOCATION'], 
        'link'      => $job['JOBLINK']
    ]);
  endforeach;
}

add_action('get_jobs_from_feed', 'get_jobs');

lubridate cast timezones

# timestamp tz conversion
DATE = "2020-01-23 13:23:45"
lubridate::ymd_hms(DATE)
ts = lubridate::ymd_hms(DATE, tz = "America/Los_Angeles")
ts
lubridate::with_tz(ts, tzone = "America/New_York")
ts_eastern = lubridate::with_tz(ts, tzone = "America/New_York")
lubridate::with_tz(ts, tzone = "UTC")
utc = lubridate::with_tz(ts, tzone = "UTC")
as.character(utc)

Delete long-running "Container Creating" pods

#!/bin/bash
kubectl --kubeconfig kubeconfig_sa-polaris-dev-us-east-1 get po --all-namespaces 2>/dev/null | grep "ContainerCreating" | grep -e '\d\dm' | while read -r line; do
    NAMESPACE=$(echo ${line} | awk '{print $1}')
    POD=$(echo ${line} | awk '{print $2}')
    kubectl --kubeconfig kubeconfig_sa-polaris-dev-us-east-1 -n ${NAMESPACE} delete po ${POD} --wait=false 2>/dev/null
done

IMAGE METADATA EXPORT

# ---------------------------------------------------------------
#                    IMAGE METADATA EXPORT 
# ---------------------------------------------------------------


# ----------------------------------------------------------------------------------------------------------------------
# Importing dependencies 
# ----------------------------------------------------------------------------------------------------------------------
from PIL.ExifTags import TAGS
from psd_tools import PSDImage
from pandas import ExcelWriter
from PIL import Image
from PIL.TiffTags import TAGS
import pandas as pd
import glob


# ----------------------------------------------------------------------------------------------------------------------
# Function to extract the metadata
# ----------------------------------------------------------------------------------------------------------------------
def get_exif(fn):
    ret = {}
    i = Image.open(fn)
    info = i._getexif(

обновление Битрикса

php_flag session.use_trans_sid on
php_value mbstring.func_overload 2
php_value mbstring.internal_encoding UTF-8

Fix Bug Phpmyadmin [sql.lib.php] + Php7.2 + - Warnings

Fix Bug Phpmyadmin [sql.lib.php] + Php7.2 + - Warnings
<h1>Warning in ./libraries/sql.lib.php#601 (phpMyAdmin)</h1>

count(): Parameter must be an array or an object that implements Countable

![1_VXjj4lPqxoNqHqt7UOIn6A](https://user-images.githubusercontent.com/60097560/73010208-fc957c80-3e37-11ea-8edf-1ecf2aec47b3.png)

It is because of phpmyadmin’s library try to counting some parameter but got wrong a code. So by looking at line 613, we find:

![1_TCanXuY2VCA2lVoSVJlacQ](https://user-images.githubusercontent.com/60097560/73010465-7d547880-3e38-11ea-940d-7dc4527ec0db.png)

<code>|| (count($analyzed_sql_results[‘select_expr’] == 1)</code>

that’s missing close bracket ‘)’ before operation with 1. So, change it to

<code>|| (count($analyzed_sql_results[‘select_expr’] == 1</code>

remove last close bracket ‘)’ at this line like this,

![image](https://user-images.githubusercontent.com/60097560/73011066-93af0400-3e39-11ea-9c1e-09336c3223d8.png)


breakdance - Качественное сохранение HTML в Markdown

## Быстрый старт[](#quickstart)

**1\. Установите**

Установить с помощью [npm](https://www.npmjs.com/) :

```
$ npm install --save breakdance
```

Или установить с [пряжей](https://github.com/yarnpkg/yarn) :

```
$ yarn add breakdance
```

**2\. Конвертировать немного HTML!**

Добавьте следующий код для `example.js` запуска `$ node example` :

копия

```js
var breakdance = require('breakdance');
console.log(breakdance('<strong>The freaks come out at night!</strong>'));
//=> '**The freaks come out at night!**'
```

puppeteer - Отличное решение для работы с браузером

Домащняя страница:

https://github.com/puppeteer/puppeteer


Примеры кода и API:

https://github.com/puppeteer/puppeteer/blob/v2.0.0/docs/api.md#puppeteerlaunchoptions


Нормальные примеры:

http://thecodebarbarian.com/control-chrome-from-node-js-with-puppeteer.html


JS PROTOTYPE

  function Shape(sideLengths) { // FUNKCJA REPREZENTUJACA OBIEKT JEST ZARAZEM JEGO KONSTRUKTOREM
    this._name = '';
    this._sideLengths = sideLengths;
  }
  
  Shape.prototype.getPerimeter = function() {
    return this._sideLengths.reduce(function(prev, current){ // DOBRA METODA DO SUMOWANIA ELEMENTÓW TABLICY
      return prev + current;
    })
  }
  
  Shape.prototype.getArea = function() {
    return this._sideLengths[0] * this._sideLengths[1];
  }

  Shape.prototype.toString = function() { // METODA toString OBIEKTU Shape BEDZIE DZIEDZICZONA PRZEZ POZOSTAŁEM KLASY TRIANGLE I SQUARE I RECTANGLE
      return "[object] " + "[" + this._name + "]";
  }
  
  function Rectangle(sideLenghts) {
    
    Shape.call(this, [sideLenghts[0], sideLenghts[1], sideLenghts[0], sideLenghts[1]]); // POŻYCZENIE KONSTRUKTORA
    this._name = 'Prostokąt';
  }

  Rectangle.prototype = Object.create(Shape.prototype); // UTWORZENIE NOWEGO OBIEKTU PROTOTYPU KTÓRY DZIEDZICZY PO DOCELOWYM OBIEKCIE
  Rectan

python tools to query data from Athena in AWS (amazon)

import os
import math
import pandas as pd
import traceback
#import boto3
from pyathena import connect
from pyathena.util import as_pandas

""" ARGUMENTS """

# set connections params
params = {
    'region': 'eu-west-1',
    'bucket': 's3://MY_BUCKET',
    'path': 'MY_PATH_IN_MY_BUCKET',
    'aws_access_key_id': aws_access_key_id,
    'aws_secret_access_key': aws_secret_access_key
}


""" FUNCTIONS """

## bytes converter
def convert_size(size_bytes:int)->str:
    if size_bytes == 0:
        return "0B"
    size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
    i = int(math.floor(math.log(size_bytes, 1024)))
    p = math.pow(1024, i)
    s = round(size_bytes / p, 2)
    return "%s %s" % (s, size_name[i])


## display cursor information after executing a query
def get_info(cursor):
    print('[info] state: %s --> %s'%(cursor.state, cursor.state_change_reason) if not cursor.state_change_reason is None else '[info] state: %s'%cursor.state)
    print('[info] datetime: submis

mobile menu bug fix

// REMOVE IN NEW SITES as we dont have this issue anymore
jQuery(".navbar-menu-block > .grid-y > .cell.show-for-medium:last-child").removeClass("show-for-medium");

// fix blank space above mobile menu
jQuery(".navbar-menu-block > .grid-y > .cell.auto:first-child").removeClass("auto");

Selector adyacente

Este se conoce como un selector adyacente. Seleccionará solamente el elemento que es inmediatamente precedido por el primer elemento. En éste caso, solo el primer párrafo después de cada ul tendrá texto rojo.
<div id="container">
  <ul>
   <li> List Item </li>
   <li> List Item </li>
   <li> List Item </li>
   <li> List Item </li>
  </ul>
  <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor. </p> <!--red-->
 </div>

ul + p {
  color: red;
}

Responsive Media Queries

// MOBILE
@media (max-width: 767px)


// TABLET
@media (max-width: 1024px)

get s3 bucket size

Saved from https://serverfault.com/questions/84815/how-can-i-get-the-size-of-an-amazon-s3-bucket
aws s3 ls --summarize --human-readable --recursive s3://bucket-name/

Store Procedure c# call methods


using InsightIn.Health.Enrollment.BusinessEntities;
using InsightIn.Health.Enrollment.Helpers;
using InsightIn.Health.Enrollment.Lib.App_Logic;
using InsightIn.Health.Enrollment.Lib.App_Logic.Business_Entities;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.SqlClient;
using System.Dynamic;
using System.Linq;
using System.Text;
using Measure = InsightIn.Health.Enrollment.Lib.App_Logic.Business_Entities.Measure;

namespace InsightIn.Health.Enrollment.BusinessLogicLayer
{
    public partial class ContractBLL
    {
        private string GetBasicQuery(RootQueryStructure rootQueryStructure)
        {
            StringBuilder stringBuilder = new StringBuilder();
            int top = 20;

            if (rootQueryStructure.masterQueryStructure != null && rootQueryStructure.masterQueryStructure.Count > 1)
            {
                top = 10;
            }

  

Output debug info if on VPN

This snippet outputs whatever you feed it, but only to users on our VPN.
if ( $_SERVER['REMOTE_ADDR'] == '91.123.204.64' ) {
    print_r( $msg );
}