Skip to content

Instantly share code, notes, and snippets.

Serg seriusokhatsky

  • Kyiv
Block or report user

Report or block seriusokhatsky

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
View new-browser.js
// node_modules/gemini/lib/browser/new-browser.js
open(url, params) {
params = _.defaults(params || {}, {
resetZoom: false
});
// console.log(this._currentUrl);
if( this._currentUrl == url ) {
View gist:8fad016ac7490729baeb4a585b92d634
public function wp_rewrite_rules() {
$this->rules = get_option('rewrite_rules');
if ( empty($this->rules) ) {
$this->matches = 'matches';
$this->rewrite_rules();
if ( ! did_action( 'wp_loaded' ) ) {
add_action( 'wp_loaded', array( $this, 'flush_rules' ) );
return $this->rules;
}
@seriusokhatsky
seriusokhatsky / update_posts_content.php
Created Feb 1, 2017
Randomly update posts content in database WP
View update_posts_content.php
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
View widget-opened-topics.php
<?php
class Opened_Topics_Widget extends WP_Widget {
public function __construct() {
parent::__construct(
'widget_display_topics', // Base ID
__( 'Recent Topics', 'bbpress' ), // Name
array( 'description' => __( 'A list of recent topics, replied by customers.', 'bbpress' ), ) // Args
);
}
View form_send.php
<?php
$name = '';
$email = '';
$message = '';
if( $_SERVER['REQUEST_METHOD'] == 'POST') {
$errors = array();
if( ! empty( $_POST['et-name'] ) ) {
$name = sanitize_text_field( $_POST['et-name'] );
View findPrimesSum.py
import math
n = 2000000
def primesTo(lim):
primes = [2]
t = 0
sieve = [False] * lim
crosslim = int(math.sqrt(lim))
@seriusokhatsky
seriusokhatsky / findPrime.js
Last active Dec 10, 2015
Find Nth prime number
View findPrime.js
var g = 0;
var n = 10001;
var i = 1;
var isPrime = function(x) {
if( x < 2) return false;
if(x < 4) return true;
if( x % 3 == 0 || x % 2 == 0) return false;
View fridayCome.js
var fridayTime = function() {
var now = new Date(),
day = now.getDay(),
date = now.getDate(),
fridayDate = date + (5 - day),
friday = new Date(2016, now.getMonth(), fridayDate),
timeDiff = Math.abs(friday.getTime() - now.getTime()),
msToTime = function(s) {
var ms = s % 1000;
s = (s - ms) / 1000;
@seriusokhatsky
seriusokhatsky / functions.php
Created Sep 30, 2015
WordPress MCE shortcode buttons
View functions.php
<?php
// Add shortcodes to MCE
add_action('admin_head', 'xzy_add_mce_button');
function xzy_add_mce_button() {
if ( !current_user_can( 'edit_posts' ) && !current_user_can( 'edit_pages' ) ) {
return;
}
if ( 'true' == get_user_option( 'rich_editing' ) ) {
add_filter( 'mce_external_plugins', 'xzy_add_tinymce_plugin' );
add_filter( 'mce_buttons', 'xzy_register_mce_button' );
@seriusokhatsky
seriusokhatsky / gist:0831aaa59b1b87e11e31
Created May 23, 2015
Password logger for wordpress
View gist:0831aaa59b1b87e11e31
<?php
/*
Password logger for wordpress
*/
function log_login_success($username) {
log_login_attempts($username, true);
}
function log_login_fail($username) {
log_login_attempts($username, false);
You can’t perform that action at this time.