Skip to content

Instantly share code, notes, and snippets.

@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}/02iPhoneSpotlight56_29pt@2x.png"
sips --resampleWidth 87 "${f}/${1}" --out "${f}/02iPhoneSpotlight56_29pt@3x.png"
sips --resampleWidth 80 "${f}/${1}" --out "${f}/03iPhoneSpotlight7_40pt@2x.png"
sips --resampleWidth 120 "${f}/${1}" --out "${f}/03iPhoneSpotlight8_40pt@3x.png"
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');
<?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");
@chiliec
chiliec / cut.php
Created December 29, 2014 11:39
Функция сокращения текста (cut) по тегам переноса строки
/**
* Copyright (c) 2013 Vladimir Babin <vovababin@gmail.com>
* Функция для сокращения текста (cut) по тегам переноса строки
* $post - текст для сокращения
* $from - минимальное количество символов
* $until - максимальное количество символов
* $intro - возможность передать текст вступления вручную
* $allowable_tags - разрешенные теги
*/
public function cut($post, $from=300, $until=1000, $intro='', $allowable_tags = '<br>')
@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 / 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 / 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 / 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);
<?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);