Skip to content

Instantly share code, notes, and snippets.

@stansidel
stansidel / activate_swap.sh
Last active August 29, 2015 13:56
Activate swap file on Ubuntu (based on the tutorial for DigitalOcean - https://www.digitalocean.com/community/articles/how-to-add-swap-on-ubuntu-12-04)
sudo dd if=/dev/zero of=/swapfile bs=1024 count=1024k
sudo mkswap /swapfile
sudo swapon /swapfile
echo "/swapfile none swap sw 0 0 " | sudo tee -a /etc/fstab
echo 0 | sudo tee /proc/sys/vm/swappiness
echo vm.swappiness = 0 | sudo tee -a /etc/sysctl.conf
sudo chown root:root /swapfile
sudo chmod 0600 /swapfile
swapon -s
@stansidel
stansidel / chef_vagrant_error
Last active August 29, 2015 13:56
An error on vagrant when using intercity/chef-repo
Recipe: bluepill::default
* gem_package[i18n] action install (up to date)
* gem_package[bluepill] action install
- install version 0.0.66 of package bluepill
* directory[/etc/bluepill] action create
- create new directory /etc/bluepill
- change owner from '' to 'root'
- change group from '' to '0'
@stansidel
stansidel / README.md
Last active August 29, 2015 14:01
Autostart Dropbox and Google Drive on a Mac OS X machine when an encrypted volume is mounted. Should work for Linux too

Dropbox and Google Drive autostart script

If you store your Dropbox and Google Drive folders on an encrypted drive it happens that the apps start before the volume is mounted on the system startup. Then you have to quit the app and run it again. This script aims to solve this problem.

The script is design for and tested on Mac OS X Mavericks. It should work on Linux too. For Windows solution look here.

Usage

  1. Create an app from this script (dropbox_autostart.sh) using Automator as described here. Save it in any folder under any name, e.g. as dropbox_autostart.app file under your Home folder.
  2. Change value of the volume variable in the script to your encrypted volume path.
@stansidel
stansidel / qCleaner.php
Created June 26, 2014 02:49
qTranslate translations cleaner v2
<?php
/*
* qCleaner is a script for undoing the mangling of content
* done by the qTranslate wordpress plugin. It retains the content in the language,
* while removing all other content translations.
*
* Set your wordpress database credentials and language code for the language
* that you wish to retain, and run the script to remove all other language versions
* of your content, along with the qTranslate HTML comment markers.
*
@stansidel
stansidel / mandrill-webhook.txt
Created September 4, 2014 04:19
Mandrill post body causing error in griddler-mandrill gem
mandrill_events=%5B%7B%22event%22%3A%22inbound%22%2C%22ts%22%3A1409722224%2C%22msg%22%3A%7B%22raw_msg%22%3A%22Received%3A+from+mail.chel.rostagroup.ru+%28unknown+%5B95.78.164.69%5D%29%5Cn%5Ctby+ip-10-196-133-123+%28Postfix%29+with+ESMTP+id+0E7D280412%5Cn%5Ctfor+%3Crobot%40tenders.alvik74.ru%3E%3B+Wed%2C++3+Sep+2014+05%3A30%3A19+%2B0000+%28UTC%29%5CnX-Spam-Checker-Version%3A+SpamAssassin+3.1.7+%282006-10-05%29%5CnX-Spam-Level%3A+%5CnX-Spam-Status%3A+No%2C+score%3D-195.7+required%3D4.0+tests%3DBAYES_50%2CHTML_40_50%2C%5Cn%5CtHTML_IMAGE_ONLY_16%2CHTML_MESSAGE%2CRATWARE_GECKO_BUILD%2CUSER_IN_WHITELIST%2C%5Cn%5CtUSER_IN_WHITELIST_TO+autolearn%3Dno+version%3D3.1.7%5CnX-Spam-Report%3A+%5Cn%5Ct%2A++1.7+RATWARE_GECKO_BUILD+Bulk+email+fingerprint+%28Gecko+faked%29+found%5Cn%5Ct%2A+-100+USER_IN_WHITELIST+From%3A+address+is+in+the+whitelist%5Cn%5Ct%2A+-100+USER_IN_WHITELIST_TO+address+is+listed+in+%27whitelist_to%27%5Cn%5Ct%2A++0.5+HTML_40_50+BODY%3A+Message+is+40%25+to+50%25+HTML%5Cn%5Ct%2A++0.0+HTML_MESSAGE+BODY%3A+HTM
@stansidel
stansidel / individual1.pas
Last active August 29, 2015 14:15
Решение задач на Pascal
Program HelloWorld(output);
var m: integer;
var s: string;
begin
m := -1;
while (m < 1) or (m > 12) do
Begin
Write('Введите номер месяца (1-12): ');
Readln(m);
End;
@stansidel
stansidel / individual1.vba
Last active August 29, 2015 14:15
Решение задач на VBA
Sub Individual1()
Do
m = InputBox("Введите номер месяца (1-12)")
Loop While m < 1 Or m > 12
Select Case m
Case 1
s = "январь"
Case 2
s = "февраль"
Case 3
@stansidel
stansidel / access_log
Created February 20, 2015 11:13
alvik74.ru YaMetrika issue
$ cat /var/log/httpd/access_log | grep YandexMetrika
213.180.206.197 - - [20/Feb/2015:10:00:48 +0300] "GET / HTTP/1.0" 200 15741 "-" "Mozilla/5.0 (compatible; YandexMetrika/2.0; +http://yandex.com/bots mtmon2.yandex.ru)"
5.255.253.42 - - [20/Feb/2015:10:02:07 +0300] "GET /catalog/id/15305/ HTTP/1.0" 200 14198 "-" "Mozilla/5.0 (compatible; YandexMetrika/3.0; +http://yandex.com/bots)"
5.255.253.42 - - [20/Feb/2015:10:02:28 +0300] "GET /catalog/id/18903/ HTTP/1.0" 200 13639 "-" "Mozilla/5.0 (compatible; YandexMetrika/3.0; +http://yandex.com/bots)"
5.255.253.42 - - [20/Feb/2015:10:05:00 +0300] "GET /catalog/id/17585/ HTTP/1.0" 200 14228 "-" "Mozilla/5.0 (compatible; YandexMetrika/3.0; +http://yandex.com/bots)"
213.180.206.197 - - [20/Feb/2015:10:05:08 +0300] "GET / HTTP/1.0" 200 15528 "-" "Mozilla/5.0 (compatible; YandexMetrika/2.0; +http://yandex.com/bots mtmon2.yandex.ru)"
5.255.253.42 - - [20/Feb/2015:10:06:32 +0300] "GET /catalog/id/19556/ HTTP/1.0" 200 14131 "-" "Mozilla/5.0 (compatible; YandexMetrika/3.0;
<p>
All of the 5th grade teachers and students from Springer went on a field trip to an archaeology museum.
Tickets were
<code data-math-formula="$6.00" data-math-type="mathjax">
<span class="katex-holder"></span>
<span class="mathjax-holder">
<script type="math/tex">$6.00</script> <!-- This digit is not visible -->
</span>
</code>
each for teachers and
@stansidel
stansidel / get_last_N_days_filter.php
Created May 13, 2015 09:23
Функция для форматирования поля отбора от текущей даты на N дней назад для Битрикс (Bitrix)
<?php
function getNDaysBack($daysCount, $php_format = false) {
// php_format должен быть равен 'Y-m-d' для выборки по свойствам CIBlockElement::GetList
// в остальных случаях, например, для CSaleOrder::GetList этот параметр не нужно указывать
if($php_format === false) {
// получим полный формат сайта
$site_format = CSite::GetDateFormat("FULL");
global $DB;
// переведем формат сайта в формат PHP