Full tutorial: http://hofmannsven.com/2013/laboratory/wordpress-post-like-system/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Drupal\node\NodeInterface; | |
use Drupal\Core\Template\Attribute; | |
use Drupal\Core\Url; | |
/** | |
* Implements hook_preprocess_page() for page.html.twig. | |
*/ | |
function THEME_preprocess_page(&$vars) { | |
// Add sitename and slogan to page. | |
$vars['site_name'] = \Drupal::config('system.site')->get('name'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Filter Elasticsearch posts by current language. | |
*/ | |
add_filter( 'ep_formatted_args', function( $formatted_args, $args ) { | |
if ( function_exists( 'pll_current_language' ) ) { | |
$lang = pll_current_language(); | |
if ( $lang !== false ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array | |
( | |
[from] => 0 | |
[size] => 54 | |
[sort] => Array | |
( | |
[0] => Array | |
( | |
[meta_value_num] => Array | |
( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
states = ["AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DC", "DE", "FL", "GA", | |
"HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", | |
"MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", | |
"NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", | |
"SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
us_state_abbrev = { | |
'Alabama': 'AL', | |
'Alaska': 'AK', | |
'Arizona': 'AZ', | |
'Arkansas': 'AR', | |
'California': 'CA', | |
'Colorado': 'CO', | |
'Connecticut': 'CT', | |
'Delaware': 'DE', | |
'Florida': 'FL', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# * eth0 = Internet interface (DHCP) | |
# * eth1 = LAN interface (192.168.1.0/24) | |
# * eth2 = DMZ interface (172.16.0.0/16) | |
# * Traffic open from firewall to internet | |
# * Traffic open and translated from LAN and DMZ to internet | |
# * Traffic open from LAN to Firewall | |
# * Traffic open from LAN to DMZ | |
# * Traffic open from internet to a DMZ web server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ansible playbook to setup HTTPS using Let's encrypt on nginx. | |
The Ansible playbook installs everything needed to serve static files from a nginx server over HTTPS. | |
The server pass A rating on [SSL Labs](https://www.ssllabs.com/). | |
To use: | |
1. Install [Ansible](https://www.ansible.com/) | |
2. Setup an Ubuntu 16.04 server accessible over ssh | |
3. Create `/etc/ansible/hosts` according to template below and change example.com to your domain | |
4. Copy the rest of the files to an empty directory (`playbook.yml` in the root of that folder and the rest in the `templates` subfolder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// A query without any settings will use default values. | |
// This will result in a "*:*" query, 10 rows, all fields. | |
$query = new Solarium_Query_Select; | |
$result = $client->select($query); | |
echo 'Number of results found: ' . $result->getNumFound(); | |
// The resultset is iterable, you could also use $result->getDocuments() to get an array with documents. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tweepy import StreamListener | |
from tweepy import Stream | |
import tweepy | |
import json | |
import telebot | |
import requests | |
CONSUMER_KEY = 'XXXXXXXXXXXXXXXXXXXXXXX' | |
CONSUMER_SECRET = 'XXXXXXXXXXXXXXXXXXXXXXX' | |
ACCESS_KEY = 'XXXXXXXXXXXXXXXXXXXXXXX' |
NewerOlder