Skip to content

Instantly share code, notes, and snippets.

Sokratis Galiatsis sokratisg

Block or report user

Report or block sokratisg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sokratisg
sokratisg / functions.php
Created Feb 21, 2014
WordPress - Restrict Media access per user
View functions.php
/* Restrict users viewing their own attachments */
add_filter('pre_get_posts', 'restrict_media');
function restrict_media($arg) {
global $user_ID;
if ( current_user_can('editor') ) { // Disable this to apply on all roles
if ($arg->query['post_type'] == 'attachment' && is_admin()) {
$arg->query['author'] = $user_ID;
$arg->query_vars['author'] = $user_ID;
}
}
@sokratisg
sokratisg / myisam_to_innodb.sql
Last active Aug 29, 2015
DDL for MyISAM to InnoDB conversion
View myisam_to_innodb.sql
SELECT CONCAT('ALTER TABLE `',table_schema,'`.`',table_name,'` engine=InnoDB;') FROM information_schema.tables WHERE TABLE_SCHEMA='<MY_DATABASE>' AND ENGINE = 'MyISAM';
View grok_tester.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'grok-pure'
require 'pp'
grok = Grok.new
grok.add_patterns_from_file("grok-patterns")
pattern = 'your_grok_pattern'
@sokratisg
sokratisg / lircd.conf
Created Jan 11, 2015
Supertel Pilot TV Code 396 (Sony)
View lircd.conf
# Please make this file available to others
# by sending it to <lirc@bartelmus.de>
#
# this config file was automatically generated
# using lirc-0.9.0-pre1(default) on Sun Jan 11 20:58:28 2015
#
# contributed by
#
# brand: /home/pi/lircd.conf
# model no. of remote control:
@sokratisg
sokratisg / technicolor_telnetlib.py
Created Jan 24, 2015
Technicolor telnetlib example
View technicolor_telnetlib.py
#!/usr/bin/env python
#
import telnetlib
import sys
max_wait = 2
prompt = "=>"
tn = telnetlib.Telnet("192.168.1.254","23")
tn.read_until("Username : ", max_wait)
View netflow_nsel_reorder.yaml
---
148:
- 4
- :nf_f_conn_id
8:
- 4
- :nf_f_src_addr_ipv4
7:
- 2
- :nf_f_src_port
@sokratisg
sokratisg / es_idx_replication.sh
Created Apr 8, 2015
Shell oneliner to update replicas of all elasticsearch indices
View es_idx_replication.sh
for i in `curl -XGET http://localhost:9200/_cat/indices | awk '{print $3}'`; do echo "curl -XPUT 'localhost:9200/$i/_settings' -d '{\"index\":{\"number_of_replicas\":1}}'"; done
@sokratisg
sokratisg / wp_update_content.sql
Created May 24, 2015
WP convert http to https
View wp_update_content.sql
UPDATE wp_posts
SET post_content = ( Replace (post_content, 'src="http://', 'src="//') )
WHERE Instr(post_content, 'jpeg') > 0
OR Instr(post_content, 'jpg') > 0
OR Instr(post_content, 'gif') > 0
OR Instr(post_content, 'png') > 0;
UPDATE wp_posts
SET post_content = ( Replace (post_content, "src='http://", "src='//") )
WHERE Instr(post_content, 'jpeg') > 0
@sokratisg
sokratisg / vimrc
Created Sep 13, 2014
vim-enhanced configuration
View vimrc
" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below. If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed. It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
@sokratisg
sokratisg / gist:7894195
Created Dec 10, 2013
json_decode example
View gist:7894195
<?php
$json = '{"image_intro":"storage\/images\/media\/fotografies\/thumbnail.jpg","float_intro":"","image_intro_alt":"fragkoul
$obj = json_decode($json);
echo $obj->{'image_intro'} . '<br>';
?>
You can’t perform that action at this time.