Skip to content

Instantly share code, notes, and snippets.

<?php
$token = ''; // access_token
$antigate_key = ''; // http://antigate.com/panel.php?action=showkey
$online = api('account.setOnline', 'access_token='.$token); // Продлеваем online на 15 минут
if(isset($online["error"]["captcha_img"])) {
$img_captcha = $online["error"]["captcha_img"];
$captcha_sid = $online["error"]["captcha_sid"];
$antigate_response = antigate($antigate_key, $img_captcha);
//var_dump($antigate_response);
@chiliec
chiliec / disquss-close-comments.php
Created August 18, 2014 13:14
Дебажил DISQUS
<?php
$url ='https://disqus.com/api/3.0/threads/close.json?api_secret=xxx...';
$header = array("Accept: application/json");
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_URL, $url);
@chiliec
chiliec / postach.html
Last active August 29, 2015 14:05
Syntax highlighter for Postach.io
<script type='text/javascript'>
window.exports = {
activate : function (a,b,c) {
$("pre").addClass("prettyprint linenums");
PR.prettyPrint();
}
}
</script>
<script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js?autoload=true&callback=activate"></script>
@chiliec
chiliec / jquery.markitup.js
Last active August 29, 2015 14:06
Replacement Hover to Click for dropMenus in markItUp!
// ----------------------------------------------------------------------------
// markItUp! Universal MarkUp Engine, JQuery plugin
// v 1.1.12
// Dual licensed under the MIT and GPL licenses.
// ----------------------------------------------------------------------------
// Copyright (C) 2007-2011 Jay Salvat
// http://markitup.jaysalvat.com/
// ----------------------------------------------------------------------------
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@chiliec
chiliec / translit.php
Last active August 29, 2015 14:10
Функция транслитерации урл
public function translit($str) {
$iso9_table = array(
'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', 'Ѓ' => 'G',
'Ґ' => 'G', 'Д' => 'D', 'Е' => 'E', 'Ё' => 'YO', 'Є' => 'YE',
'Ж' => 'ZH', 'З' => 'Z', 'Ѕ' => 'Z', 'И' => 'I', 'Й' => 'J',
'Ј' => 'J', 'І' => 'I', 'Ї' => 'YI', 'К' => 'K', 'Ќ' => 'K',
'Л' => 'L', 'Љ' => 'L', 'М' => 'M', 'Н' => 'N', 'Њ' => 'N',
'О' => 'O', 'П' => 'P', 'Р' => 'R', 'С' => 'S', 'Т' => 'T',
'У' => 'U', 'Ў' => 'U', 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'TS',
'Ч' => 'CH', 'Џ' => 'DH', 'Ш' => 'SH', 'Щ' => 'SHH', 'Ъ' => '',
@chiliec
chiliec / cut.php
Created December 29, 2014 11:39
Функция сокращения текста (cut) по тегам переноса строки
/**
* Copyright (c) 2013 Vladimir Babin <[email protected]>
* Функция для сокращения текста (cut) по тегам переноса строки
* $post - текст для сокращения
* $from - минимальное количество символов
* $until - максимальное количество символов
* $intro - возможность передать текст вступления вручную
* $allowable_tags - разрешенные теги
*/
public function cut($post, $from=300, $until=1000, $intro='', $allowable_tags = '<br>')
<?php
ini_set("memory_limit", "1024M");
set_time_limit(0);
// setup the WordPress environment
define( "WP_INSTALLING", true );
require( dirname(__FILE__) . '/wp-load.php' );
require( 'wp-blog-header.php' );
require_once( ABSPATH . WPINC . '/registration.php' );
require_once(ABSPATH . "wp-admin/includes/taxonomy.php");
function change_slug_for_attachment($id) {
$post = get_post($id);
$post->post_name = uniqid('attachment');
wp_update_post($post);
}
add_action('add_attachment', 'change_slug_for_attachment');
@chiliec
chiliec / icon_resizer.sh
Created October 30, 2016 18:46
Icon AppStore resize. Usage: ./icon_resizer.sh path_to_big_icon.png
#!/bin/bash
f=$(pwd)
sips --resampleWidth 29 "${f}/${1}" --out "${f}/01iPhoneSpotlight56_29pt.png"
sips --resampleWidth 58 "${f}/${1}" --out "${f}/[email protected]"
sips --resampleWidth 87 "${f}/${1}" --out "${f}/[email protected]"
sips --resampleWidth 80 "${f}/${1}" --out "${f}/[email protected]"
sips --resampleWidth 120 "${f}/${1}" --out "${f}/[email protected]"
@chiliec
chiliec / wordpress_import.php
Last active May 28, 2017 20:37
export posts to wordpress
<?php
date_default_timezone_set('America/Los_Angeles');
$mysqli = new mysqli("localhost:8889", "root", "root", "kripipastacom");
if ($mysqli->connect_errno) {
echo "Не удалось подключиться к MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
$file = fopen('export.xml', "w+");
$header = '<?xml version="1.0" encoding="UTF-8" ?>