вторник, 16 июля 2013 г.
четверг, 30 мая 2013 г.
How do I find what dependencies a rpm file has?
RPM is a Package Manager for popular distribution such as Red Hat,
Suse and many others. It is a powerful command line package management
system for installing uninstalling, verifying, querying, and updating
Linux computer software packages.
You can finding out what dependencies a rpm file has i.e. it will tell you what you need to install package with following command:
rpm -qpR {.rpm-file}
rpm -qR {package-name}
Otherwise you can try to install it end will get error message if some of the deps wouldnot be installed.
rpm -ivh {.rpm-file}
You can finding out what dependencies a rpm file has i.e. it will tell you what you need to install package with following command:
rpm -qpR {.rpm-file}
rpm -qR {package-name}
Otherwise you can try to install it end will get error message if some of the deps wouldnot be installed.
rpm -ivh {.rpm-file}
среда, 10 апреля 2013 г.
Ставим Puppet в CentOS 6
Как ни забавно, но столкнулся со странной проблемой при установке сабжа. Скорее это по моему недосмотру, но все же. Суть -- вылетало с ошибкой при попытке установки ruby-libs.
Пофиксилось командой yum clean all, очень рекомендую ее сделать перед установкой паппета.
Далее, в репе нет puppet, поэтому нам надо добавить репу с паппетом:
Далее просто yum install puppet чтобы установить клиент, ну и yum install puppet-master , чтобы установить сервер.
Пофиксилось командой yum clean all, очень рекомендую ее сделать перед установкой паппета.
Далее, в репе нет puppet, поэтому нам надо добавить репу с паппетом:
rpm -ivh http://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release-6-6.noarch.rpm
Далее просто yum install puppet чтобы установить клиент, ну и yum install puppet-master , чтобы установить сервер.
вторник, 9 апреля 2013 г.
[PUPPET] Ставим пакеты из backports
Возникла необходимость поставить пакет из бекпортов через apt-get с помощью паппета.
Для этого необходимо проделать примерно следующее (кусок манифеста из рабочего проекта)
Для этого необходимо проделать примерно следующее (кусок манифеста из рабочего проекта)
class collectd { # directories and filenames setup $apt_sources_dir = '/etc/apt/sources.list.d' $apt_sources_file = 'backports.list' file { "{$apt_sources_dir}/{$apt_sources_file}": ensure => file, content => 'deb http://backports.debian.org/debian-backports squeeze-backports main', } # exec { "apt-get update": command => "/usr/bin/apt-get update", onlyif => "/bin/sh -c '[ ! -f /var/cache/apt/pkgcache.bin ] || /usr/bin/find /etc/apt/* -cnewer /var/cache/apt/pkgcache.bin | /bin/grep . > /dev/null'", } # installing package package { "collectd-core/squeeze-backports": ensure => "latest", require => Exec['apt-get update'], } }
понедельник, 1 апреля 2013 г.
[ANDROID] "Переносим" данные из внутренней памяти телефона на флеш-карту
1. Определитесь где у вас на (флешке) будут храниться перенесенные данные и создайте для них папку. Например Bind
2. Создайте в только что созданной папке еще одну папку с именем gameloft
3. Перенесите в нее содержимое папки /mnt/sdcard/gameloft/games
4. Скачайте с маркета бесплатное приложение Script Manager
5. Решите где у вас будет лежать скрипт ==> Создайте папку Scripts.
6. Запустите Script Manager и перейдите в эту папку.
7. Создайте новый скрипт (меню-(+)) и назовите его bind.sh
8. Щелкните по свежесозданному файлу и в появившемся меню нажмите:
Звездочку - это добавит наш скрипт в избранное.
Черепок - запуск скрипта с root привилегиями.
Шестеренку - добавит скрипт в автозагрузку.
Далее жмем кнопку Edit и открываем скрипт любимым текстовым редактором.
9. Настало время для самого сложного
Структура команды:
mount -o bind </что/хотите/смонтировать> </куда/хотите/смонтировать>
Исходя из этого у нас получается:
mount -o bind /mnt/sdcard2/bind/gameloft /mnt/sdcard/gameloft/games
иными словами мы говорим системе что содержимое папки /sdcard/gameloft/games находится в папке /sdcard2/bind/gameloft
10. В открытом файле пишем:
#!/system/bin/sh
mount -o bind /mnt/sdcard2/bind/gameloft /mnt/sdcard/gameloft/games
exit 0
11. Сохраняем файл и закрываем текстовый редактор.
12. Жмем кнопку Run и идем в папку /gameloft/games
Если кэши в ней видны, значит вы все сделали правильно, можно запустить и проверить игру.
При следующей перезагрузке скрипт выполнится автоматически.
По аналогии переносим другие данные просто дописывая в этот скрипт.
2. Создайте в только что созданной папке еще одну папку с именем gameloft
3. Перенесите в нее содержимое папки /mnt/sdcard/gameloft/games
4. Скачайте с маркета бесплатное приложение Script Manager
5. Решите где у вас будет лежать скрипт ==> Создайте папку Scripts.
6. Запустите Script Manager и перейдите в эту папку.
7. Создайте новый скрипт (меню-(+)) и назовите его bind.sh
8. Щелкните по свежесозданному файлу и в появившемся меню нажмите:
Звездочку - это добавит наш скрипт в избранное.
Черепок - запуск скрипта с root привилегиями.
Шестеренку - добавит скрипт в автозагрузку.
Далее жмем кнопку Edit и открываем скрипт любимым текстовым редактором.
9. Настало время для самого сложного
Структура команды:
mount -o bind </что/хотите/смонтировать> </куда/хотите/смонтировать>
Исходя из этого у нас получается:
mount -o bind /mnt/sdcard2/bind/gameloft /mnt/sdcard/gameloft/games
иными словами мы говорим системе что содержимое папки /sdcard/gameloft/games находится в папке /sdcard2/bind/gameloft
10. В открытом файле пишем:
#!/system/bin/sh
mount -o bind /mnt/sdcard2/bind/gameloft /mnt/sdcard/gameloft/games
exit 0
#!/system/bin/sh ##Cashe gameloft mount -o bind /mnt/sdcard2/bind/gameloft /mnt/sdcard/gameloft/games ##Cashe Spectral Souls mount -o bind /mnt/sdcard2/bind/hyperdevbox /mnt/sdcard/hyperdevbox ##Maps 2GIS mount -o bind /mnt/sdcard2/bind/2gisMobile /mnt/sdcard/2gisMobile exit 0
11. Сохраняем файл и закрываем текстовый редактор.
12. Жмем кнопку Run и идем в папку /gameloft/games
Если кэши в ней видны, значит вы все сделали правильно, можно запустить и проверить игру.
При следующей перезагрузке скрипт выполнится автоматически.
По аналогии переносим другие данные просто дописывая в этот скрипт.
вторник, 26 марта 2013 г.
[PHP] Useful code snippets
Email PHP errors instead of displaying it
By default, most servers are set to display an error message when an error occured in one of your script. For security reasons, you may want to get an email with the error, instead of displaying it to the public.
// Our custom error handler function nettuts_error_handler($number, $message, $file, $line, $vars){ $email = " An error ($number) occurred on line $line and in the file: $file. $message "; $email .= "" . print_r($vars, 1) . ""; $headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Email the error to someone... error_log($email, 1, 'you@youremail.com', $headers); // Make sure that you decide how to respond to errors (on the user's side) // Either echo an error message, or kill the entire project. Up to you... // The code below ensures that we only "die" if the error was more than // just a NOTICE. if ( ($number !== E_NOTICE) && ($number < 2048) ) { die("There was an error. Please try again later."); } } // We should use our custom function to handle errors. set_error_handler('nettuts_error_handler'); // Trigger an error... (var doesn't exist) echo $somevarthatdoesnotexist;
Detect location by IP
Here is an useful code snippet to detect the location of a specific IP. The function below takes one IP as a parameter, and returns the location of the IP. If no location is found,
UNKNOWN
is returned.function detect_city($ip) { $default = 'UNKNOWN'; if (!is_string($ip) || strlen($ip) < 1 || $ip == '127.0.0.1' || $ip == 'localhost') $ip = '8.8.8.8'; $curlopt_useragent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)'; $url = 'http://ipinfodb.com/ip_locator.php?ip=' . urlencode($ip); $ch = curl_init(); $curl_opt = array( CURLOPT_FOLLOWLOCATION => 1, CURLOPT_HEADER => 0, CURLOPT_RETURNTRANSFER => 1, CURLOPT_USERAGENT => $curlopt_useragent, CURLOPT_URL => $url, CURLOPT_TIMEOUT => 1, CURLOPT_REFERER => 'http://' . $_SERVER['HTTP_HOST'], ); curl_setopt_array($ch, $curl_opt); $content = curl_exec($ch); if (!is_null($curl_info)) { $curl_info = curl_getinfo($ch); } curl_close($ch); if ( preg_match('{
Display Facebook fans count in full text
Want to display how many Facebook fans do you have, in full text, on your blog? It’s very easy using the following snippet:
function fb_fan_count($facebook_name){ // Example: https://graph.facebook.com/digimantra $data = json_decode(file_get_contents("https://graph.facebook.com/".$facebook_name)); echo $data->likes; }
Get info about your memory usage
In order to optimize your scripts, you may definitely want to know how many amount of RAM they use on your server. This snippet will check memory and then print initial, final and peak usages.
echo "Initial: ".memory_get_usage()." bytes \n"; /* prints Initial: 361400 bytes */ // let's use up some memory for ($i = 0; $i < 100000; $i++) { $array []= md5($i); } // let's remove half of the array for ($i = 0; $i < 100000; $i++) { unset($array[$i]); } echo "Final: ".memory_get_usage()." bytes \n"; /* prints Final: 885912 bytes */ echo "Peak: ".memory_get_peak_usage()." bytes \n"; /* prints Peak: 13687072 bytes */
Подписаться на:
Сообщения (Atom)