Skip to content

Instantly share code, notes, and snippets.

Avatar

Serg seriusokhatsky

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 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 / 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);