Skip to content

Instantly share code, notes, and snippets.

View antonlukin's full-sized avatar

Anton Lukin antonlukin

View GitHub Profile
@iloveitaly
iloveitaly / vpn-utilities.applescript
Created July 3, 2010 19:05
Configure / create VPN connections via applescript
-- Author: Michael Bianco <http://mabblog.com/>
-- Some help from: http://discussions.info.apple.com/message.jspa?messageID=10363317
on create_vpn_service(vpn_name)
tell application "System Preferences"
reveal pane "Network"
activate
tell application "System Events"
tell process "System Preferences"
@danielbachhuber
danielbachhuber / gist:1666271
Created January 23, 2012 23:14
Grist's guest authors plugin
<?php
/* Plugin Name: Grist Authors
* Description: Handles a special 'Author' post type and co-authors for posts.
* Author: Andrew Nacin
* Author URI: http://andrewnacin.com/
*/
class Grist_Authors {
static function init() {
@lewg
lewg / wp-config-batcache.php
Created September 12, 2012 18:40
WordPress config for batcache + wptouch
<?php
/* Custom Config for Batcache */
// Determine if this is a WP Touch User Agent
function is_wptouch_user_agent() {
// This needs to match your WP Touch list!!
$useragents = array(
// Apple iOS/Webkit
"iphone", "ipod", "incognito", "webmate",
// Android OS
@thefuxia
thefuxia / plugin-class-demo.php
Last active April 11, 2024 13:50
Plugin Class Demo
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: Plugin Class Demo
* Description: How I am using the base class in plugins.
* Plugin URI:
* Version: 2012.09.29
* Author: Fuxia Scholz
* License: GPL
* Text Domain: plugin_unique_name
* Domain Path: /languages
@denji
denji / nginx-tuning.md
Last active May 24, 2024 10:14
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@nikolov-tmw
nikolov-tmw / custom-menu-panel.php
Last active February 22, 2024 21:29
This registers a custom meta box for nav menus and renders it. Obviously $my_items would ideally be not hard-coded and instead it would come somewhere from the DB. The custom items add to the menu and save properly, but will probably not be displayed correctly. You might need to hook to the 'wp_setup_nav_menu_item' filter in order to fix the men…
<?php
function my_register_menu_metabox() {
$custom_param = array( 0 => 'This param will be passed to my_render_menu_metabox' );
add_meta_box( 'my-menu-test-metabox', 'Test Menu Metabox', 'my_render_menu_metabox', 'nav-menus', 'side', 'default', $custom_param );
}
add_action( 'admin_head-nav-menus.php', 'my_register_menu_metabox' );
/**
@rodica-andronache
rodica-andronache / gist:54f3ea95bcaf76435e55
Created October 31, 2014 13:27
color picker in wordpress widget
class Color_Picker_Widget_25809 extends WP_Widget {
/**
* Widget constructor.
*
* @since 1.0
*
* @access public
*/
public function __construct() {
@UmeshSingla
UmeshSingla / functions.php
Created November 2, 2014 09:05
Post file using wp_remote_post in WordPress
<?php
$local_file = 'file_path'; //path to a local file on your server
$post_fields = array (
'name' =&gt; 'value'
);
$boundary = wp_generate_password( 24 );
$headers = array(
'content-type' =&gt; 'multipart/form-data; boundary=' . $boundary
);
$payload = '';
@ghalusa
ghalusa / youtube_id_regex.php
Created June 20, 2015 23:14
Extract the YouTube Video ID from a URL in PHP
<?php
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored)
// http://youtu.be/dQw4w9WgXcQ
// http://www.youtube.com/embed/dQw4w9WgXcQ
// http://www.youtube.com/watch?v=dQw4w9WgXcQ
// http://www.youtube.com/?v=dQw4w9WgXcQ
// http://www.youtube.com/v/dQw4w9WgXcQ
// http://www.youtube.com/e/dQw4w9WgXcQ
// http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ